addRecallBillModal.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <a-modal
  3. centered
  4. class="shelfSet-basicInfo-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. :title="'新增调回单——'+recallBillInfo.shelfName"
  8. v-model="isShow"
  9. @cancel="isShow = false"
  10. width="60%">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-form-model id="shelfSet-basicInfo-form" ref="ruleForm" :model="queryParam" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  13. <a-row :gutter="10">
  14. <a-col :md="8" :sm="24">
  15. <a-form-model-item label="产品编码"><a-input allowClear placeholder="请输入产品编码" v-model.tirm="queryParam.productCode" /></a-form-model-item>
  16. </a-col>
  17. <a-col :md="8" :sm="24">
  18. <a-form-item label="产品名称"><a-input allowClear placeholder="请输入产品名称" v-model.tirm="queryParam.productName" /></a-form-item>
  19. </a-col>
  20. <a-col :md="8" :sm="24">
  21. <a-form-model-item label="滞销天数">
  22. <a-input-group>
  23. <a-row>
  24. <a-col :md="11" :sm="24">
  25. <a-input-number
  26. id="shelfMonitoringList-minUnsalableDays"
  27. v-model="queryParam.unsalableDaysBegin"
  28. :precision="0"
  29. :min="0"
  30. :max="999999"
  31. placeholder="起始天数"
  32. style="width: 100%;display: inline-block;"
  33. />
  34. </a-col>
  35. <a-col :md="2" :sm="24"><span style="display: block;text-align: center;line-height: 32px;">至</span></a-col>
  36. <a-col :md="11" :sm="24">
  37. <a-input-number
  38. id="shelfMonitoringList-maxUnsalableDays"
  39. v-model="queryParam.unsalableDaysEnd"
  40. :precision="0"
  41. :min="0"
  42. :max="999999"
  43. placeholder="截止天数"
  44. style="width: 100%;display: inline-block;"
  45. />
  46. </a-col>
  47. </a-row>
  48. </a-input-group>
  49. </a-form-model-item>
  50. </a-col>
  51. <a-col :span="24" style="text-align: right;padding-right: 30px;">
  52. <a-button type="primary" @click="$refs.recallBillTable.refresh(true)" id="outboundOrderList-refresh">查询</a-button>
  53. <a-button style="margin-left: 8px" @click="resetSearchForm" id="outboundOrderList-reset">重置</a-button>
  54. </a-col>
  55. </a-row>
  56. </a-form-model>
  57. <div class="tableCon">
  58. <div style="margin-bottom: 16px">
  59. <a-button type="primary" @click="handleSave">新增调回单</a-button>
  60. <span class="tableSpan" v-if="totalCategory ||totalNum">
  61. <template>
  62. 已选
  63. <span>{{ totalCategory }}</span>
  64. 款产品,共
  65. <span>{{ totalNum }}</span>
  66. </template>
  67. </span>
  68. <span v-if="totalNum ||totalCategory"><a-checkbox @change="isShowChooseList" :checked="showChecked" size="small">仅显示已选产品</a-checkbox></span>
  69. </div>
  70. <s-table
  71. class="sTable"
  72. ref="recallBillTable"
  73. size="small"
  74. :rowKey="(record) => record.id"
  75. :row-selection="{columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: record.confirmQty <= 0 } })}"
  76. @rowSelection="onSelectChange"
  77. :columns="columns"
  78. :data="loadData"
  79. :scroll="{ y: 450 }"
  80. :showPagination="false"
  81. bordered>
  82. <template slot="confirmQty" slot-scope="text, record">
  83. <div v-if="record.confirmQty === 0">--</div>
  84. <a-input-number
  85. v-else
  86. size="small"
  87. v-model="record.confirmQty"
  88. :readonly="hasChecked(record.id)"
  89. @change="changeNums(record)"
  90. :precision="0"
  91. :min="1"
  92. :max="record.recallBillQty?record.qty - record.recallBillQty :record.qty"
  93. placeholder="请输入"
  94. :style="{ width: '100%' }"
  95. ></a-input-number>
  96. </template>
  97. </s-table>
  98. </div>
  99. </a-spin>
  100. </a-modal>
  101. </template>
  102. <script>
  103. import { STable } from '@/components'
  104. import { commonMixin } from '@/utils/mixin'
  105. import { shelfControlList } from '@/api/shelf'
  106. import { shelfRecallSave } from '@/api/shelfRecall'
  107. export default {
  108. name: 'AddRecallBillModal',
  109. mixins: [commonMixin],
  110. components: { STable },
  111. props: {
  112. openModal: {
  113. // 弹框显示状态
  114. type: Boolean,
  115. default: false
  116. },
  117. recallBillInfo: {
  118. type: Object,
  119. default: () => {
  120. return {}
  121. }
  122. }
  123. },
  124. data () {
  125. return {
  126. spinning: false,
  127. isShow: this.openModal, // 是否打开弹框
  128. formItemLayout: {
  129. labelCol: { span: 5 },
  130. wrapperCol: { span: 17 }
  131. },
  132. queryParam: {
  133. // 查询条件
  134. shelfSn: '',
  135. productCode: undefined,
  136. productName: undefined,
  137. unsalableDaysBegin: undefined,
  138. unsalableDaysEnd: undefined
  139. },
  140. columns: [
  141. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  142. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '15%', align: 'center' },
  143. {
  144. title: '产品编码',
  145. dataIndex: 'productCode',
  146. width: '20%',
  147. align: 'center',
  148. customRender: function (text) {
  149. return text || '--'
  150. }
  151. },
  152. {
  153. title: '产品名称',
  154. dataIndex: 'productName',
  155. width: '30%',
  156. align: 'center',
  157. customRender: function (text) {
  158. return text || '--'
  159. },
  160. ellipsis: true
  161. },
  162. {
  163. title: '最大库容',
  164. dataIndex: 'maxQty',
  165. width: '15%',
  166. align: 'center',
  167. customRender: function (text) {
  168. return text || text == 0 ? text : '--'
  169. }
  170. },
  171. {
  172. title: '补货在途',
  173. dataIndex: 'replenishBillQty',
  174. width: '15%',
  175. align: 'center',
  176. customRender: function (text) {
  177. return text || text == 0 ? text : '--'
  178. }
  179. },
  180. {
  181. title: '调回在途',
  182. dataIndex: 'recallBillQty',
  183. width: '15%',
  184. align: 'center',
  185. customRender: function (text) {
  186. return text || text == 0 ? text : '--'
  187. }
  188. },
  189. {
  190. title: '货架库存',
  191. dataIndex: 'qty',
  192. width: '15%',
  193. align: 'center',
  194. customRender: function (text) {
  195. return text || text == 0 ? text : '--'
  196. }
  197. },
  198. {
  199. title: '单位',
  200. dataIndex: 'productUnit',
  201. width: '15%',
  202. align: 'center',
  203. customRender: function (text) {
  204. return text || '--'
  205. }
  206. },
  207. {
  208. title: '滞销天数',
  209. dataIndex: 'unsalableDays',
  210. width: '15%',
  211. align: 'center',
  212. customRender: function (text) {
  213. return text || text == 0 ? text : '--'
  214. }
  215. },
  216. { title: '调回数量', width: '20%', align: 'center', scopedSlots: { customRender: 'confirmQty' } }
  217. ],
  218. showChecked: false,
  219. rowSelectionInfo: null,
  220. // 加载数据方法 必须为 Promise 对象
  221. loadData: parameter => {
  222. // 获取列表
  223. this.spinning = true
  224. if (!this.checkValueRange()) {
  225. this.spinning = false
  226. return
  227. }
  228. this.queryParam.shelfSn = this.recallBillInfo.shelfSn
  229. return shelfControlList(this.queryParam).then(res => {
  230. let data
  231. if (res.status == 200) {
  232. data = res.data
  233. if (this.showChecked) {
  234. data = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  235. }
  236. for (var i = 0; i < data.length; i++) {
  237. data[i].no = i + 1
  238. const row = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  239. const cur = row.find(item => item.id == data[i].id)
  240. data[i].confirmQty = cur ? cur.confirmQty : (data[i].confirmQty || data[i].recallBillQty ? data[i].qty - data[i].recallBillQty : data[i].qty)
  241. data[i].checked = !cur
  242. }
  243. }
  244. this.spinning = false
  245. return data
  246. })
  247. }
  248. }
  249. },
  250. methods: {
  251. onSelectChange (obj) {
  252. // 获取选中列表
  253. this.rowSelectionInfo = obj || null
  254. },
  255. hasChecked: function (value) {
  256. const row = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  257. const cur = row.find(item => item.id == value)
  258. return !cur
  259. },
  260. changeNums (data) {
  261. const row = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  262. const cur = row.find(item => item.id == data.id)
  263. if (cur) {
  264. cur.confirmQty = data.confirmQty
  265. }
  266. row.splice()
  267. },
  268. // 确定新增回调单
  269. handleSave () {
  270. const _this = this
  271. if (this.rowSelectionInfo.selectedRows && this.rowSelectionInfo.selectedRows.length == 0) {
  272. this.$message.warning('请先选择产品')
  273. return
  274. }
  275. const flag = this.rowSelectionInfo.selectedRows.some(con => !con.confirmQty && con.confirmQty != 0)
  276. if (flag) {
  277. this.$message.warning('调回数量能为空!')
  278. return
  279. }
  280. const arr = []
  281. this.rowSelectionInfo.selectedRows.forEach((item, index) => {
  282. arr.push({
  283. shelfSn: item.shelfSn,
  284. shelfPlaceSn: item.shelfPlaceSn,
  285. shelfPlaceCode: item.shelfPlaceCode,
  286. productSn: item.productSn,
  287. productCode: item.productCode,
  288. productName: item.productName,
  289. qty: item.confirmQty
  290. })
  291. })
  292. _this.spinning = true
  293. const params = {
  294. shelfSn: this.recallBillInfo.shelfSn,
  295. detailList: arr
  296. }
  297. shelfRecallSave(params).then(res => {
  298. _this.spinning = false
  299. if (res.status == 200) {
  300. _this.$emit('ok')
  301. _this.isShow = false
  302. this.$refs.recallBillTable.clearSelected()
  303. _this.$message.success('保存并确认成功')
  304. }
  305. })
  306. },
  307. isShowChooseList (e) {
  308. this.showChecked = e.target.checked
  309. this.$refs.recallBillTable.refresh(true)
  310. },
  311. // 重置
  312. resetSearchForm () {
  313. const obj = {
  314. // 查询条件
  315. shelfSn: this.recallBillInfo.shelfSn,
  316. productCode: undefined,
  317. productName: undefined,
  318. unsalableDaysBegin: undefined,
  319. unsalableDaysEnd: undefined
  320. }
  321. this.queryParam = obj
  322. this.$refs.recallBillTable.refresh(true)
  323. },
  324. // 校验滞销天数数值范围
  325. checkValueRange () {
  326. const isONull = this.queryParam.unsalableDaysBegin === null || this.queryParam.unsalableDaysBegin === undefined
  327. const isOEmpty = this.queryParam.unsalableDaysBegin === ''
  328. const isOZero = this.queryParam.unsalableDaysBegin === 0
  329. const isTNull = this.queryParam.unsalableDaysEnd === null || this.queryParam.unsalableDaysEnd === undefined
  330. const isTEmpty = this.queryParam.unsalableDaysEnd === ''
  331. const isTZero = this.queryParam.unsalableDaysEnd === 0
  332. // 第一个为空(可为null可为空字符)第二个不为空
  333. // 第一个不为空第二个为空(可为null可为空字符)
  334. // 第一个大于第二个
  335. if ((isONull || isOEmpty) && (this.queryParam.unsalableDaysEnd || isTZero)) {
  336. this.$message.info('请输入正确的滞销天数查询范围!')
  337. return false
  338. }
  339. if ((this.queryParam.unsalableDaysBegin || isOZero) && (isTNull || isTEmpty)) {
  340. this.$message.info('请输入正确的滞销天数查询范围!')
  341. return false
  342. }
  343. if (this.queryParam.unsalableDaysBegin > this.queryParam.unsalableDaysEnd) {
  344. this.$message.info('请输入正确的滞销天数查询范围!')
  345. return false
  346. }
  347. this.queryParam.unsalableDaysBegin = this.queryParam.unsalableDaysBegin > 999999999 ? 999999999 : this.queryParam.unsalableDaysBegin
  348. this.queryParam.unsalableDaysEnd = this.queryParam.unsalableDaysEnd > 999999999 ? 999999999 : this.queryParam.unsalableDaysEnd
  349. return true
  350. }
  351. },
  352. watch: {
  353. // 父页面传过来的弹框状态
  354. openModal (newValue, oldValue) {
  355. this.isShow = newValue
  356. },
  357. // 重定义的弹框状态
  358. isShow (newValue, oldValue) {
  359. if (!newValue) {
  360. this.$emit('close')
  361. this.$refs.ruleForm.resetFields()
  362. } else {
  363. this.$nextTick(() => {
  364. this.$refs.recallBillTable.clearSelected()
  365. this.showChecked = false
  366. this.resetSearchForm()
  367. })
  368. }
  369. }
  370. },
  371. computed: {
  372. totalNum () {
  373. let ret = 0
  374. this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.map(item => {
  375. ret = ret + item.confirmQty
  376. })
  377. return ret
  378. },
  379. totalCategory () {
  380. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.length
  381. }
  382. }
  383. }
  384. </script>
  385. <style lang="less">
  386. .shelfSet-basicInfo-modal {
  387. .ant-modal-body {
  388. padding: 40px 40px 24px;
  389. }
  390. .ant-form-item {
  391. margin-bottom: 15px;
  392. }
  393. .btn-cont {
  394. text-align: center;
  395. margin: 35px 0 10px;
  396. }
  397. .tableSpan {
  398. margin: 0 16px;
  399. span {
  400. margin: 0 10px;
  401. color: red;
  402. font-weight: bold;
  403. }
  404. }
  405. }
  406. </style>