chooseShelfProduct.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <a-modal
  3. centered
  4. class="chooseShelf-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. :title="mtitle"
  8. v-model="isShow"
  9. @cancel="isShow = false"
  10. width="80%">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-tabs type="card">
  13. <a-tab-pane :defaultActiveKey="curTab" v-model="curTab" :key="1" tab="待补货产品">
  14. <!-- 搜索条件 -->
  15. <div class="table-page-search-wrapper">
  16. <a-form-model
  17. ref="ruleForm"
  18. class="form-model-con"
  19. layout="inline"
  20. :model="queryParam"
  21. @keyup.enter.native="$refs.table.refresh(true)" >
  22. <a-row :gutter="15">
  23. <a-col :md="4" :sm="24">
  24. <a-form-model-item label="产品编码">
  25. <a-input id="chooseShelf-code" ref="searchProductCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  26. </a-form-model-item>
  27. </a-col>
  28. <a-col :md="4" :sm="24">
  29. <a-form-model-item label="产品名称">
  30. <a-input id="chooseShelf-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  31. </a-form-model-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24">
  34. <a-form-model-item label="产品分类">
  35. <ProductType id="chooseShelf-productType" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
  36. </a-form-model-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-model-item label="库存情况">
  40. <a-checkbox-group v-model.trim="queryParam.stockStateList" :options="options" />
  41. </a-form-model-item>
  42. </a-col>
  43. <a-col :md="4" :sm="12" style="margin-bottom: 10px;">
  44. <a-button type="primary" @click="$refs.table.refresh(true)" id="chooseShelf-refresh">查询</a-button>
  45. <a-button style="margin-left: 5px" @click="resetSearchForm" id="chooseShelf-reset">重置</a-button>
  46. </a-col>
  47. </a-row>
  48. </a-form-model>
  49. </div>
  50. <div class="chooseShelf-modal-table">
  51. <div class="table-operator">
  52. <div>
  53. <a-button type="primary" @click="handlePlAdd">批量添加</a-button>
  54. <span style="margin-left: 10px;" v-if="selectTotal">已选{{ selectTotal }}项</span>
  55. </div>
  56. <div>
  57. <a-icon type="info-circle" />
  58. 此界面仅显示货架上需要补货的产品
  59. </div>
  60. </div>
  61. <!-- 列表 -->
  62. <s-table
  63. class="sTable"
  64. ref="table"
  65. size="small"
  66. :rowKey="(record) => record.id"
  67. :row-selection="{columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: record.includeFlag == 1 } })}"
  68. @rowSelection="rowSelectionFun"
  69. :columns="columns"
  70. :data="loadData"
  71. :style="{ height: '500px' }"
  72. :scroll="{ y: 450 }"
  73. :showPagination="false"
  74. bordered>
  75. <!-- 售价 -->
  76. <template slot="salePrice" slot-scope="text, record">
  77. <div style="display: flex;align-items: center;" @dblclick.stop>
  78. <a-input-number
  79. size="small"
  80. v-model="record.price"
  81. :precision="2"
  82. :min="0"
  83. :max="999999"
  84. style="width: 100%;"
  85. placeholder="请输入" />
  86. <span style="color: red;margin: 0 2px;font-size: 14px;" v-if="record.origSalePriceFlag == 1">原</span>
  87. <span v-else>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
  88. </div>
  89. </template>
  90. <!-- 销售数量 -->
  91. <template slot="nums" slot-scope="text, record">
  92. <div @dblclick.stop>
  93. <a-input-number
  94. size="small"
  95. v-model="record.salesNums"
  96. :precision="0"
  97. :min="0"
  98. :max="999999"
  99. style="width: 100%;"
  100. placeholder="请输入" />
  101. </div>
  102. </template>
  103. <!-- 操作 -->
  104. <template slot="action" slot-scope="text, record">
  105. <a-button
  106. size="small"
  107. type="link"
  108. class="button-primary"
  109. @click.stop="handleAdd(record)"
  110. v-if="record.includeFlag != 1"
  111. id="productInfoList-edit-btn">添加</a-button>
  112. <span style="color:#999;" v-else>已添加</span>
  113. <a-button
  114. size="small"
  115. type="link"
  116. class="button-primary"
  117. @click.stop="handleDetail(record)"
  118. id="productInfoList-detail-btn"
  119. style="margin-left: 5px;">销售记录</a-button>
  120. </template>
  121. </s-table>
  122. </div>
  123. </a-tab-pane>
  124. <a-tab-pane :key="2" tab="全部货架产品">
  125. <!-- 搜索条件 -->
  126. <div class="table-page-search-wrapper">
  127. <a-form-model
  128. ref="ruleForm1"
  129. class="form-model-con"
  130. layout="inline"
  131. :model="queryParam1"
  132. @keyup.enter.native="$refs.table1.refresh(true)" >
  133. <a-row :gutter="15">
  134. <a-col :md="6" :sm="24">
  135. <a-form-model-item label="产品编码">
  136. <a-input id="chooseShelf-code1" v-model.trim="queryParam1.productCode" allowClear placeholder="请输入产品编码"/>
  137. </a-form-model-item>
  138. </a-col>
  139. <a-col :md="6" :sm="24">
  140. <a-form-model-item label="产品名称">
  141. <a-input id="chooseShelf-name1" v-model.trim="queryParam1.productName" allowClear placeholder="请输入产品名称"/>
  142. </a-form-model-item>
  143. </a-col>
  144. <a-col :md="6" :sm="24">
  145. <a-form-model-item label="产品分类">
  146. <ProductType id="chooseShelf-productType1" :isDealer="true" @change="changeProductType1" v-model="productType1"></ProductType>
  147. </a-form-model-item>
  148. </a-col>
  149. <a-col :md="6" :sm="12" style="margin-bottom: 10px;">
  150. <a-button type="primary" @click="$refs.table1.refresh(true)" id="chooseShelf-refresh">查询</a-button>
  151. <a-button style="margin-left: 5px" @click="resetSearchForm1" id="chooseShelf-reset">重置</a-button>
  152. </a-col>
  153. </a-row>
  154. </a-form-model>
  155. </div>
  156. <div class="chooseShelf-modal-table">
  157. <!-- 列表 -->
  158. <s-table
  159. class="sTable"
  160. ref="table1"
  161. size="small"
  162. :rowKey="(record) => record.id"
  163. :columns="columns1"
  164. :data="loadData1"
  165. :style="{ height: '500px' }"
  166. :scroll="{ y: 450 }"
  167. :showPagination="false"
  168. bordered>
  169. </s-table>
  170. </div>
  171. </a-tab-pane>
  172. </a-tabs>
  173. </a-spin>
  174. <!-- 销售记录 -->
  175. <product-salesRecord-modal ref="salseRecord" :openModal="showRecord" @close="showRecord=false" />
  176. </a-modal>
  177. </template>
  178. <script>
  179. import { commonMixin } from '@/utils/mixin'
  180. import { STable } from '@/components'
  181. import ProductType from '../../common/productType.js'
  182. import productSalesRecordModal from './productSalesRecordModal.vue'
  183. import { queryWaitReplenish, queryShelfProduct } from '@/api/shelfReplenish'
  184. export default {
  185. name: 'OutinDetailModal',
  186. components: { STable, ProductType, productSalesRecordModal },
  187. mixins: [commonMixin],
  188. props: {
  189. openModal: {
  190. // 弹框显示状态
  191. type: Boolean,
  192. default: false
  193. },
  194. baseData: {
  195. type: Object,
  196. default: function () {
  197. return null
  198. }
  199. }
  200. },
  201. data () {
  202. return {
  203. spinning: false,
  204. advanced: false,
  205. showRecord: false,
  206. isShow: this.openModal, // 是否打开弹框
  207. options: [
  208. { label: '库存充足', value: 'stockEnough' },
  209. { label: '部分缺货', value: 'portionStockout' },
  210. { label: '全部缺货', value: 'allStockout' }
  211. ],
  212. curTab: 1,
  213. productType: [],
  214. queryParam: {
  215. productCode: '', // 产品编码
  216. productName: '', // 产品名称
  217. productTypeSn1: '', // 产品一级分类
  218. productTypeSn2: '', // 产品二级分类
  219. productTypeSn3: '', // 产品三级分类
  220. stockStateList: []
  221. },
  222. // 加载数据方法 必须为 Promise 对象
  223. loadData: parameter => {
  224. this.spinning = true
  225. this.queryParam.shelfSn = this.baseData.shelfSn
  226. this.queryParam.customerSn = this.baseData.customerSn
  227. this.queryParam.salePriceType = this.baseData.salePriceType
  228. this.queryParam.salesBillSn = this.baseData.salesBillSn
  229. return queryWaitReplenish(Object.assign(parameter, this.queryParam)).then(res => {
  230. let data
  231. if (res.status == 200) {
  232. data = res.data
  233. const no = 0
  234. for (var i = 0; i < data.length; i++) {
  235. data[i] = data[i].shelfProductApi
  236. data[i].no = no + i + 1
  237. data[i].salesNums = data[i].replenishBillWaitQty
  238. data[i].putCost = data[i].cost
  239. }
  240. }
  241. this.spinning = false
  242. return data
  243. })
  244. },
  245. rowSelectionInfo: null,
  246. // -------- 全部产品 --------
  247. productType1: [],
  248. queryParam1: {
  249. productCode: '', // 产品编码
  250. productName: '', // 产品名称
  251. productTypeSn1: '', // 产品一级分类
  252. productTypeSn2: '', // 产品二级分类
  253. productTypeSn3: '' // 产品三级分类
  254. },
  255. // 加载数据方法 必须为 Promise 对象
  256. loadData1: parameter => {
  257. this.spinning = true
  258. this.queryParam1.shelfSn = this.baseData.shelfSn
  259. this.queryParam1.customerSn = this.baseData.customerSn
  260. this.queryParam1.salePriceType = this.baseData.salePriceType
  261. this.queryParam1.salesBillSn = this.baseData.salesBillSn
  262. return queryShelfProduct(Object.assign(parameter, this.queryParam1)).then(res => {
  263. let data
  264. if (res.status == 200) {
  265. data = res.data
  266. const no = 0
  267. for (var i = 0; i < data.length; i++) {
  268. data[i].no = no + i + 1
  269. }
  270. }
  271. this.spinning = false
  272. return data
  273. })
  274. }
  275. }
  276. },
  277. computed: {
  278. mtitle () {
  279. return '货架产品' + (this.baseData && this.baseData.shelfName ? this.baseData.shelfName : '')
  280. },
  281. selectTotal () {
  282. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.length
  283. },
  284. columns () {
  285. const arr = [
  286. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  287. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  288. { title: '产品编码', dataIndex: 'productCode', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  289. { title: '产品名称', dataIndex: 'productName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  290. { title: '最大库容', dataIndex: 'maxQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  291. { title: '货架库存', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  292. { title: '补货在途', dataIndex: 'replenishBillQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  293. { title: '调回在途', dataIndex: 'recallBillQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  294. { title: '待补货数量', dataIndex: 'replenishBillWaitQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  295. { title: '门店库存数量', dataIndex: 'qplsStockQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  296. { title: '单位', dataIndex: 'productUnit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  297. { title: '售价', dataIndex: 'price', scopedSlots: { customRender: 'salePrice' }, width: '8%', align: 'center' },
  298. { title: '销售数量', dataIndex: 'salesNums', scopedSlots: { customRender: 'nums' }, width: '8%', align: 'center' },
  299. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  300. ]
  301. return arr
  302. },
  303. columns1 () {
  304. const arr = [
  305. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  306. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  307. { title: '产品编码', dataIndex: 'productCode', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  308. { title: '产品名称', dataIndex: 'productName', width: '25%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  309. { title: '最大库容', dataIndex: 'maxQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  310. { title: '货架库存', dataIndex: 'qty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  311. { title: '补货在途', dataIndex: 'replenishBillQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  312. { title: '调回在途', dataIndex: 'recallBillQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  313. { title: '单位', dataIndex: 'productUnit', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  314. ]
  315. return arr
  316. }
  317. },
  318. methods: {
  319. cansel () {
  320. this.isShow = false
  321. },
  322. // 销售记录
  323. handleDetail (row) {
  324. this.showRecord = true
  325. this.$refs.salseRecord.getDetail(this.baseData.customerSn, row.productSn, row)
  326. },
  327. // 表格选中项
  328. rowSelectionFun (obj) {
  329. this.rowSelectionInfo = obj || null
  330. },
  331. // 产品分类 change
  332. changeProductType (val, opt) {
  333. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  334. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  335. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  336. },
  337. // 添加
  338. handleAdd (row) {
  339. const clist = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  340. const blist = this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys || []
  341. const i = clist.findIndex(item => item.id == row.id)
  342. const k = blist.findIndex(item => item == row.id)
  343. console.log(i, k)
  344. if (i >= 0) {
  345. clist.splice(i, 1)
  346. }
  347. if (k >= 0) {
  348. blist.splice(k, 1)
  349. }
  350. this.$emit('add', row)
  351. },
  352. // 批量添加
  353. handlePlAdd () {
  354. if (this.selectTotal) {
  355. this.$emit('plAdd', this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || [])
  356. } else {
  357. this.$message.info('请选择产品')
  358. }
  359. },
  360. resetSearchForm () {
  361. this.queryParam.productCode = ''
  362. this.queryParam.productName = ''
  363. this.queryParam.productTypeSn1 = ''
  364. this.queryParam.productTypeSn2 = ''
  365. this.queryParam.productTypeSn3 = ''
  366. this.productType = []
  367. this.queryParam.stockStateList = []
  368. this.$refs.ruleForm.resetFields()
  369. this.$refs.table.clearSelected()
  370. this.$refs.table.refresh(true)
  371. },
  372. reload () {
  373. this.$refs.table.clearSelected()
  374. this.$refs.table.refresh()
  375. },
  376. // ---------- 全部产品----------
  377. // 产品分类 change
  378. changeProductType1 (val, opt) {
  379. this.queryParam1.productTypeSn1 = val[0] ? val[0] : ''
  380. this.queryParam1.productTypeSn2 = val[1] ? val[1] : ''
  381. this.queryParam1.productTypeSn3 = val[2] ? val[2] : ''
  382. },
  383. resetSearchForm1 () {
  384. this.queryParam1.productCode = ''
  385. this.queryParam1.productName = ''
  386. this.queryParam1.productTypeSn1 = ''
  387. this.queryParam1.productTypeSn2 = ''
  388. this.queryParam1.productTypeSn3 = ''
  389. this.productType1 = []
  390. this.$refs.ruleForm1.resetFields()
  391. this.$refs.table1.refresh(true)
  392. }
  393. },
  394. watch: {
  395. // 父页面传过来的弹框状态
  396. openModal (newValue, oldValue) {
  397. this.isShow = newValue
  398. },
  399. // 重定义的弹框状态
  400. isShow (newValue, oldValue) {
  401. if (!newValue) {
  402. this.$emit('close')
  403. } else {
  404. this.$nextTick(() => {
  405. this.curTab = 1
  406. })
  407. }
  408. }
  409. }
  410. }
  411. </script>
  412. <style lang="less">
  413. .chooseShelf-modal {
  414. .ant-modal-body {
  415. padding: 0;
  416. .chooseShelf-modal-table{
  417. padding: 0 20px 10px;
  418. .table-operator{
  419. padding:0 10px 10px 0;
  420. display:flex;
  421. justify-content: space-between;
  422. align-items: center;
  423. }
  424. }
  425. .table-page-search-wrapper{
  426. padding: 5px 20px 0;
  427. }
  428. }
  429. }
  430. </style>