list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <a-card size="small" :bordered="false" class="chainStockReportList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="chainStockReportList-form"
  8. ref="ruleForm"
  9. :model="queryParam"
  10. :rules="rules"
  11. :labelCol="labelCol"
  12. :wrapperCol="wrapperCol"
  13. @keyup.enter.native="handleSearch" >
  14. <a-row :gutter="15">
  15. <a-col :md="6" :sm="24">
  16. <a-form-model-item label="连锁店" prop="targetName">
  17. <a-select
  18. placeholder="请选择连锁店"
  19. id="chainStockReportList-targetName"
  20. allowClear
  21. v-model="queryParam.targetName"
  22. :showSearch="true"
  23. option-filter-prop="children"
  24. :filter-option="filterOption">
  25. <a-select-option v-for="item in allocateTypeList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  26. </a-select>
  27. </a-form-model-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-model-item label="产品编码">
  31. <a-input id="productInfoList-code" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  32. </a-form-model-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24">
  35. <a-form-model-item label="产品名称">
  36. <a-input id="productInfoList-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  37. </a-form-model-item>
  38. </a-col>
  39. <template v-if="advanced">
  40. <a-col :md="6" :sm="24">
  41. <a-form-model-item label="原厂编码">
  42. <a-input id="productInfoList-origCode" v-model.trim="queryParam.productOrigCode" allowClear placeholder="请输入原厂编码"/>
  43. </a-form-model-item>
  44. </a-col>
  45. <a-col :md="6" :sm="24">
  46. <a-form-model-item label="产品品牌">
  47. <a-select
  48. placeholder="请选择产品品牌"
  49. id="productInfoList-productBrandSn"
  50. allowClear
  51. v-model="queryParam.productBrandSn"
  52. :showSearch="true"
  53. option-filter-prop="children"
  54. :filter-option="filterOption">
  55. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  56. </a-select>
  57. </a-form-model-item>
  58. </a-col>
  59. <a-col :md="6" :sm="24">
  60. <a-form-model-item label="产品分类">
  61. <a-cascader
  62. @change="changeProductType"
  63. change-on-select
  64. v-model="productType"
  65. expand-trigger="hover"
  66. :options="productTypeList"
  67. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  68. id="productInfoList-productType"
  69. placeholder="请选择产品分类"
  70. allowClear />
  71. </a-form-model-item>
  72. </a-col>
  73. </template>
  74. <a-col :md="6" :sm="24" style="margin-top: 3px;">
  75. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="chainStockReportList-refresh">查询</a-button>
  76. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chainStockReportList-reset">重置</a-button>
  77. <a @click="advanced=!advanced" style="margin-left: 8px">
  78. {{ advanced ? '收起' : '展开' }}
  79. <a-icon :type="advanced ? 'up' : 'down'"/>
  80. </a>
  81. </a-col>
  82. </a-row>
  83. </a-form-model>
  84. </div>
  85. <!-- 合计 -->
  86. <a-alert type="info" showIcon style="margin-bottom:15px">
  87. <div class="ftext" slot="message">
  88. 现有库存总数量(个):<strong> {{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }} </strong>;
  89. 现有库存总成本(¥):<strong> {{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? totalData.totalCost : '--' }} </strong>。
  90. </div>
  91. </a-alert>
  92. <!-- 列表 -->
  93. <s-table
  94. class="sTable"
  95. ref="table"
  96. size="small"
  97. :rowKey="(record) => record.productSn + record.stockSn"
  98. :columns="columns"
  99. :data="loadData"
  100. :defaultLoadData="false"
  101. :scroll="{ x: 1170 }"
  102. bordered>
  103. <!-- 现有库存数量 -->
  104. <template slot="currentStockQty" slot-scope="text, record">
  105. {{ (Number(record.currentStockQty) + Number(record.freezeQty)) || 0 }}
  106. <span v-if="Number(record.freezeQty)">(冻结{{ record.freezeQty }})</span>
  107. </template>
  108. <template slot="currentStockCost" slot-scope="text, record">
  109. {{ (Number(record.currentStockCost)*1000 + Number(record.freezeCost)*1000)/1000 || 0 }}
  110. </template>
  111. <!-- 操作 -->
  112. <template slot="action" slot-scope="text, record">
  113. <a-button size="small" type="link" class="button-success" @click="goDetail(record)" id="chainStockReportList-detail-btn">详情</a-button>
  114. </template>
  115. </s-table>
  116. </a-spin>
  117. <!-- 详情 -->
  118. <chain-stock-report-detail-modal :openModal="openModal" :productSn="productSn" @close="closeModal" />
  119. </a-card>
  120. </template>
  121. <script>
  122. import { STable, VSelect } from '@/components'
  123. import chainStockReportDetailModal from './detailModal.vue'
  124. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  125. import { dealerProductTypeList } from '@/api/dealerProductType'
  126. import { reportStockList, reportStockCount } from '@/api/reportStock'
  127. export default {
  128. components: { STable, VSelect, chainStockReportDetailModal },
  129. data () {
  130. return {
  131. spinning: false,
  132. advanced: false, // 高级搜索 展开/关闭
  133. tableHeight: 0,
  134. queryParam: { // 查询条件
  135. targetName: undefined,
  136. productCode: '', // 产品编码
  137. productName: '', // 产品名称
  138. productOrigCode: '', // 原厂编码
  139. productBrandSn: undefined, // 产品品牌
  140. productTypeSn1: '', // 产品分类1
  141. productTypeSn2: '', // 产品分类2
  142. productTypeSn3: '' // 产品分类3
  143. },
  144. labelCol: { span: 8 },
  145. wrapperCol: { span: 16 },
  146. rules: {
  147. 'targetName': [{ required: true, message: '请选择连锁店', trigger: 'change' }]
  148. },
  149. disabled: false, // 查询、重置按钮是否可操作
  150. exportLoading: false,
  151. columns: [
  152. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  153. { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  154. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  155. { title: '原厂编码', dataIndex: 'productOrigCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  156. { title: '现有库存数量(个)', dataIndex: 'currentStockQty', scopedSlots: { customRender: 'currentStockQty' }, width: 165, align: 'center', sorter: true },
  157. { title: '现有库存成本(¥)', dataIndex: 'currentStockCost', scopedSlots: { customRender: 'currentStockCost' }, width: 165, align: 'center', sorter: true },
  158. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  159. ],
  160. // 加载数据方法 必须为 Promise 对象
  161. loadData: parameter => {
  162. this.disabled = true
  163. const params = Object.assign(parameter, this.queryParam)
  164. this.spinning = true
  165. if (params.targetName) {
  166. return reportStockList(params).then(res => {
  167. // 总计
  168. this.getCount(params)
  169. const data = res.data
  170. const no = (data.pageNo - 1) * data.pageSize
  171. for (var i = 0; i < data.list.length; i++) {
  172. data.list[i].no = no + i + 1
  173. }
  174. this.disabled = false
  175. this.spinning = false
  176. return data
  177. })
  178. } else {
  179. const _this = this
  180. return new Promise(function (resolve, reject) {
  181. const data = {
  182. pageNo: 1,
  183. pageSize: 10,
  184. list: [],
  185. count: 0
  186. }
  187. _this.disabled = false
  188. _this.spinning = false
  189. _this.$message.info('请选择连锁店')
  190. resolve(data)
  191. })
  192. }
  193. },
  194. productType: [],
  195. productBrandList: [], // 品牌下拉数据
  196. productTypeList: [], // 分类下拉数据
  197. allocateTypeList: [], // 调拨类型
  198. totalData: null, // 合计
  199. productSn: '',
  200. openModal: false // 弹框
  201. }
  202. },
  203. methods: {
  204. // 合计
  205. getCount (params) {
  206. reportStockCount(params).then(res => {
  207. if (res.status == 200) {
  208. this.totalData = res.data
  209. } else {
  210. this.totalData = null
  211. }
  212. })
  213. },
  214. // 查询
  215. handleSearch () {
  216. const _this = this
  217. this.$refs.ruleForm.validate(valid => {
  218. if (valid) {
  219. _this.$refs.table.refresh(true)
  220. } else {
  221. console.log('error submit!!')
  222. return false
  223. }
  224. })
  225. },
  226. // 重置
  227. resetSearchForm () {
  228. this.queryParam.targetName = undefined
  229. this.queryParam.productCode = ''
  230. this.queryParam.productName = ''
  231. this.queryParam.productOrigCode = ''
  232. this.queryParam.productBrandSn = undefined
  233. this.queryParam.productTypeSn1 = ''
  234. this.queryParam.productTypeSn2 = ''
  235. this.queryParam.productTypeSn3 = ''
  236. this.productType = []
  237. this.$refs.ruleForm.resetFields()
  238. this.totalData = null
  239. this.$refs.table.clearTable()
  240. },
  241. // 详情
  242. goDetail (row) {
  243. this.productSn = row.productSn
  244. this.openModal = true
  245. },
  246. // 关闭弹框
  247. closeModal () {
  248. this.productSn = ''
  249. this.openModal = false
  250. },
  251. // 产品分类 change
  252. changeProductType (val, opt) {
  253. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  254. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  255. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  256. },
  257. // 产品品牌 列表
  258. getProductBrand () {
  259. dealerProductBrandQuery({}).then(res => {
  260. if (res.status == 200) {
  261. this.productBrandList = res.data
  262. } else {
  263. this.productBrandList = []
  264. }
  265. })
  266. },
  267. // 产品分类 列表
  268. getProductType () {
  269. dealerProductTypeList({}).then(res => {
  270. if (res.status == 200) {
  271. this.productTypeList = res.data
  272. } else {
  273. this.productTypeList = []
  274. }
  275. })
  276. },
  277. filterOption (input, option) {
  278. return (
  279. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  280. )
  281. }
  282. },
  283. beforeRouteEnter (to, from, next) {
  284. next(vm => {
  285. vm.getProductBrand()
  286. vm.getProductType()
  287. })
  288. }
  289. }
  290. </script>