list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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="dealerSn">
  17. <a-select
  18. placeholder="请选择连锁店"
  19. id="chainStockReportList-dealerSn"
  20. allowClear
  21. v-model="queryParam.dealerSn"
  22. :showSearch="true"
  23. option-filter-prop="children"
  24. :filter-option="filterOption">
  25. <a-select-option v-for="item in linkageGroupData" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</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="chainStockReportList-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="chainStockReportList-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="chainStockReportList-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="chainStockReportList-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="chainStockReportList-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 { linkageGroupList } from '@/api/reportData'
  127. import { reportStockList, reportStockCount } from '@/api/reportStock'
  128. export default {
  129. components: { STable, VSelect, chainStockReportDetailModal },
  130. data () {
  131. return {
  132. spinning: false,
  133. advanced: false, // 高级搜索 展开/关闭
  134. tableHeight: 0,
  135. queryParam: { // 查询条件
  136. dealerSn: undefined,
  137. productCode: '', // 产品编码
  138. productName: '', // 产品名称
  139. productOrigCode: '', // 原厂编码
  140. productBrandSn: undefined, // 产品品牌
  141. productTypeSn1: '', // 产品分类1
  142. productTypeSn2: '', // 产品分类2
  143. productTypeSn3: '' // 产品分类3
  144. },
  145. labelCol: { span: 8 },
  146. wrapperCol: { span: 16 },
  147. rules: {
  148. 'dealerSn': [{ required: true, message: '请选择连锁店', trigger: 'change' }]
  149. },
  150. disabled: false, // 查询、重置按钮是否可操作
  151. exportLoading: false,
  152. columns: [
  153. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  154. { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  155. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  156. { title: '原厂编码', dataIndex: 'productOrigCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  157. { title: '现有库存数量(个)', dataIndex: 'currentStockQty', scopedSlots: { customRender: 'currentStockQty' }, width: 165, align: 'center', sorter: true },
  158. { title: '现有库存成本(¥)', dataIndex: 'currentStockCost', scopedSlots: { customRender: 'currentStockCost' }, width: 165, align: 'center', sorter: true },
  159. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  160. ],
  161. // 加载数据方法 必须为 Promise 对象
  162. loadData: parameter => {
  163. this.disabled = true
  164. const params = Object.assign(parameter, this.queryParam)
  165. this.spinning = true
  166. if (params.dealerSn) {
  167. if (params.dealerSn == 'all') {
  168. params.dealerSn = ''
  169. }
  170. return reportStockList(params).then(res => {
  171. // 总计
  172. this.getCount(params)
  173. const data = res.data
  174. const no = (data.pageNo - 1) * data.pageSize
  175. for (var i = 0; i < data.list.length; i++) {
  176. data.list[i].no = no + i + 1
  177. }
  178. this.disabled = false
  179. this.spinning = false
  180. return data
  181. })
  182. } else {
  183. const _this = this
  184. return new Promise(function (resolve, reject) {
  185. const data = {
  186. pageNo: 1,
  187. pageSize: 10,
  188. list: [],
  189. count: 0
  190. }
  191. _this.disabled = false
  192. _this.spinning = false
  193. _this.$message.info('请选择连锁店')
  194. resolve(data)
  195. })
  196. }
  197. },
  198. productType: [],
  199. linkageGroupData: [],
  200. productBrandList: [], // 品牌下拉数据
  201. productTypeList: [], // 分类下拉数据
  202. allocateTypeList: [], // 调拨类型
  203. totalData: null, // 合计
  204. productSn: '',
  205. openModal: false // 弹框
  206. }
  207. },
  208. methods: {
  209. // 合计
  210. getCount (params) {
  211. reportStockCount(params).then(res => {
  212. if (res.status == 200) {
  213. this.totalData = res.data
  214. } else {
  215. this.totalData = null
  216. }
  217. })
  218. },
  219. // 查询
  220. handleSearch () {
  221. const _this = this
  222. this.$refs.ruleForm.validate(valid => {
  223. if (valid) {
  224. _this.$refs.table.refresh(true)
  225. } else {
  226. console.log('error submit!!')
  227. return false
  228. }
  229. })
  230. },
  231. // 重置
  232. resetSearchForm () {
  233. this.queryParam.dealerSn = undefined
  234. this.queryParam.productCode = ''
  235. this.queryParam.productName = ''
  236. this.queryParam.productOrigCode = ''
  237. this.queryParam.productBrandSn = undefined
  238. this.queryParam.productTypeSn1 = ''
  239. this.queryParam.productTypeSn2 = ''
  240. this.queryParam.productTypeSn3 = ''
  241. this.productType = []
  242. this.$refs.ruleForm.resetFields()
  243. this.totalData = null
  244. this.$refs.table.clearTable()
  245. },
  246. // 详情
  247. goDetail (row) {
  248. this.productSn = row.productSn
  249. this.openModal = true
  250. },
  251. // 关闭弹框
  252. closeModal () {
  253. this.productSn = ''
  254. this.openModal = false
  255. },
  256. // 产品分类 change
  257. changeProductType (val, opt) {
  258. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  259. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  260. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  261. },
  262. // 产品品牌 列表
  263. getProductBrand () {
  264. dealerProductBrandQuery({}).then(res => {
  265. if (res.status == 200) {
  266. this.productBrandList = res.data
  267. } else {
  268. this.productBrandList = []
  269. }
  270. })
  271. },
  272. // 产品分类 列表
  273. getProductType () {
  274. dealerProductTypeList({}).then(res => {
  275. if (res.status == 200) {
  276. this.productTypeList = res.data
  277. } else {
  278. this.productTypeList = []
  279. }
  280. })
  281. },
  282. filterOption (input, option) {
  283. return (
  284. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  285. )
  286. },
  287. // 连锁店
  288. getLinkageGroup () {
  289. linkageGroupList({}).then(res => {
  290. const all = [{ dealerName: '全部', dealerSn: 'all' }]
  291. if (res.status == 200) {
  292. const data = res.data || []
  293. this.linkageGroupData = [...all, ...data]
  294. } else {
  295. this.linkageGroupData = all
  296. }
  297. })
  298. }
  299. },
  300. beforeRouteEnter (to, from, next) {
  301. next(vm => {
  302. vm.getLinkageGroup()
  303. vm.getProductBrand()
  304. vm.getProductType()
  305. })
  306. }
  307. }
  308. </script>