list.vue 12 KB

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