list.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <a-card size="small" :bordered="false" class="jg-page-wrap chainInventoryList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form-model layout="inline" ref="ruleForm" :model="queryParam" :rules="rules" @keyup.enter.native="handleSearch">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-model-item label="门店名称">
  10. <a-input id="chainInventoryList-storeName" v-model.trim="queryParam.storeName" allowClear placeholder="请输入门店名称"/>
  11. </a-form-model-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-model-item label="产品编码" prop="productCode">
  15. <a-input id="chainInventoryList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  16. </a-form-model-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-model-item label="原厂编码">
  20. <a-input id="chainInventoryList-productOrigCode" v-model.trim="queryParam.productOrigCode" allowClear placeholder="请输入原厂编码"/>
  21. </a-form-model-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="6" :sm="24">
  25. <a-form-model-item label="产品名称">
  26. <a-input id="chainInventoryList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  27. </a-form-model-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-model-item label="产品品牌">
  31. <ProductBrand id="chainInventoryList-productBrandSn" placeholder="请选择产品品牌" v-model="queryParam.productBrandSn"></ProductBrand>
  32. </a-form-model-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24">
  35. <a-form-model-item label="产品分类">
  36. <ProductType id="chainInventoryList-productType" placeholder="请选择产品分类" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
  37. </a-form-model-item>
  38. </a-col>
  39. </template>
  40. <a-col :md="6" :sm="24">
  41. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainInventoryList-refresh">查询</a-button>
  42. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainInventoryList-reset">重置</a-button>
  43. <a @click="advanced=!advanced" style="margin-left: 5px" id="chainInventoryList-advanced">
  44. {{ advanced ? '收起' : '展开' }}
  45. <a-icon :type="advanced ? 'up' : 'down'"/>
  46. </a>
  47. </a-col>
  48. </a-row>
  49. </a-form-model>
  50. </div>
  51. <!-- 列表 -->
  52. <s-table
  53. class="sTable fixPagination"
  54. ref="table"
  55. :style="{ height: tableHeight+68.5+'px' }"
  56. size="small"
  57. :rowKey="(record) => record.id"
  58. :columns="columns"
  59. :data="loadData"
  60. :pageSize="30"
  61. :scroll="{ y: tableHeight }"
  62. :defaultLoadData="false"
  63. bordered>
  64. <!-- 产品分类 -->
  65. <template slot="productType" slot-scope="text, record">
  66. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  67. <span v-else>--</span>
  68. </template>
  69. </s-table>
  70. </a-spin>
  71. </a-card>
  72. </template>
  73. <script>
  74. import { commonMixin } from '@/utils/mixin'
  75. // 组件
  76. import { STable, VSelect } from '@/components'
  77. import ProductType from '@/views/common/productType.js'// 产品分类
  78. import ProductBrand from '@/views/common/productBrand.js'// 产品品牌
  79. // 接口
  80. import { stockWarnList } from '@/api/stockWarn'
  81. export default {
  82. name: 'ChainInventoryList',
  83. components: { STable, VSelect, ProductType, ProductBrand },
  84. mixins: [commonMixin],
  85. data () {
  86. return {
  87. spinning: false,
  88. advanced: true, // 高级搜索 展开/关闭
  89. tableHeight: 0, // 表格高度
  90. disabled: false, // 查询、重置按钮是否可操作
  91. queryParam: { // 查询条件
  92. storeName: undefined, // 门店名称
  93. productCode: '', // 产品编码
  94. productName: '', // 产品名称
  95. productOrigCode: '', // 原厂编码
  96. productBrandSn: undefined, // 产品品牌sn
  97. productTypeSn1: undefined, // 产品分类1
  98. productTypeSn2: undefined, // 产品分类2
  99. productTypeSn3: undefined // 产品分类3
  100. },
  101. productType: [], // 产品分类默认值
  102. columns: [
  103. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  104. { title: '门店名称', dataIndex: 'storeName', align: 'left', width: '20%', customRender: function (text) { return text || '--' }, ellipsis: true },
  105. { title: '产品编码', dataIndex: 'productCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  106. { title: '产品名称', dataIndex: 'productName', align: 'left', width: '20%', customRender: function (text) { return text || '--' }, ellipsis: true },
  107. { title: '原厂编码', dataIndex: 'dealerProduct.origCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  108. { title: '产品品牌', dataIndex: 'brandName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  109. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '15%', align: 'center' },
  110. { title: '可用库存数量(个)', dataIndex: 'stockNum', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  111. ],
  112. // 加载数据方法 必须为 Promise 对象
  113. loadData: parameter => {
  114. this.disabled = true
  115. this.spinning = true
  116. return stockWarnList(Object.assign(parameter, this.queryParam)).then(res => {
  117. let data
  118. if (res.status == 200) {
  119. data = res.data
  120. const no = (data.pageNo - 1) * data.pageSize
  121. for (var i = 0; i < data.list.length; i++) {
  122. data.list[i].no = no + i + 1
  123. }
  124. this.disabled = false
  125. }
  126. this.spinning = false
  127. return data
  128. })
  129. },
  130. rules: {
  131. productCode: [{ required: true, message: '请输入产品编码', trigger: 'blur' }]
  132. }
  133. }
  134. },
  135. methods: {
  136. // 查询
  137. handleSearch () {
  138. this.$refs.ruleForm.validate(valid => {
  139. if (valid) {
  140. this.$refs.table.refresh(true)
  141. } else {
  142. this.$message.error('请输入产品编码')
  143. return false
  144. }
  145. })
  146. },
  147. // 重置
  148. resetSearchForm () {
  149. this.queryParam.storeName = undefined
  150. this.queryParam.productCode = ''
  151. this.queryParam.productName = ''
  152. this.queryParam.productOrigCode = ''
  153. this.queryParam.productBrandSn = undefined
  154. this.queryParam.productTypeSn1 = undefined
  155. this.queryParam.productTypeSn2 = undefined
  156. this.queryParam.productTypeSn3 = undefined
  157. this.productType = []
  158. this.$refs.ruleForm.resetFields()
  159. this.$refs.table.clearTable()
  160. },
  161. // 产品分类 change
  162. changeProductType (val, opt) {
  163. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  164. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  165. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  166. },
  167. // 页面初始化
  168. pageInit () {
  169. const _this = this
  170. this.$nextTick(() => { // 页面渲染完成后的回调
  171. _this.setTableH()
  172. })
  173. },
  174. // 表格高度计算
  175. setTableH () {
  176. const tableSearchH = this.$refs.tableSearch.offsetHeight
  177. this.tableHeight = window.innerHeight - tableSearchH - 180
  178. }
  179. },
  180. watch: {
  181. advanced (newValue, oldValue) {
  182. const _this = this
  183. this.$nextTick(() => { // 页面渲染完成后的回调
  184. _this.setTableH()
  185. })
  186. },
  187. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  188. this.setTableH()
  189. }
  190. },
  191. mounted () {
  192. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  193. this.pageInit()
  194. this.resetSearchForm()
  195. }
  196. },
  197. activated () {
  198. // 如果是新页签打开,则重置当前页面
  199. if (this.$store.state.app.isNewTab) {
  200. this.pageInit()
  201. this.resetSearchForm()
  202. }
  203. },
  204. beforeRouteEnter (to, from, next) {
  205. next(vm => {})
  206. }
  207. }
  208. </script>
  209. <style lang="less">
  210. .chainInventoryList-wrap{
  211. .green{
  212. color: #19be6b;
  213. }
  214. .red{
  215. color: #ed1c24;
  216. }
  217. .yellow{
  218. color: #ff9900;
  219. }
  220. .blue{
  221. color: #2db7f5;
  222. }
  223. }
  224. </style>