addRecallBillModal.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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. :precision="0"
  89. :min="1"
  90. :max="record.qty"
  91. placeholder="请输入"
  92. :style="{ width: '100%' }"
  93. ></a-input-number>
  94. </template>
  95. </s-table>
  96. </div>
  97. </a-spin>
  98. </a-modal>
  99. </template>
  100. <script>
  101. import { STable } from '@/components'
  102. import { commonMixin } from '@/utils/mixin'
  103. import { shelfControlList } from '@/api/shelf'
  104. import { shelfRecallSave } from '@/api/shelfRecall'
  105. export default {
  106. name: 'AddRecallBillModal',
  107. mixins: [commonMixin],
  108. components: { STable },
  109. props: {
  110. openModal: {
  111. // 弹框显示状态
  112. type: Boolean,
  113. default: false
  114. },
  115. recallBillInfo: {
  116. type: Object,
  117. default: () => {
  118. return {}
  119. }
  120. }
  121. },
  122. data () {
  123. return {
  124. spinning: false,
  125. isShow: this.openModal, // 是否打开弹框
  126. formItemLayout: {
  127. labelCol: { span: 5 },
  128. wrapperCol: { span: 17 }
  129. },
  130. queryParam: {
  131. // 查询条件
  132. shelfSn: '',
  133. productCode: undefined,
  134. productName: undefined,
  135. unsalableDaysBegin: undefined,
  136. unsalableDaysEnd: undefined
  137. },
  138. columns: [
  139. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  140. { title: '货位号', dataIndex: 'shelfPlaceCode', width: '15%', align: 'center' },
  141. {
  142. title: '产品编码',
  143. dataIndex: 'productCode',
  144. width: '20%',
  145. align: 'center',
  146. customRender: function (text) {
  147. return text || '--'
  148. }
  149. },
  150. {
  151. title: '产品名称',
  152. dataIndex: 'productName',
  153. width: '30%',
  154. align: 'left',
  155. customRender: function (text) {
  156. return text || '--'
  157. },
  158. ellipsis: true
  159. },
  160. {
  161. title: '最大库容',
  162. dataIndex: 'maxQty',
  163. width: '15%',
  164. align: 'center',
  165. customRender: function (text) {
  166. return text || text == 0 ? text : '--'
  167. }
  168. },
  169. {
  170. title: '补货在途',
  171. dataIndex: 'replenishBillQty',
  172. width: '15%',
  173. align: 'center',
  174. customRender: function (text) {
  175. return text || text == 0 ? text : '--'
  176. }
  177. },
  178. {
  179. title: '调回在途',
  180. dataIndex: 'recallBillQty',
  181. width: '15%',
  182. align: 'center',
  183. customRender: function (text) {
  184. return text || text == 0 ? text : '--'
  185. }
  186. },
  187. {
  188. title: '货架库存',
  189. dataIndex: 'qty',
  190. width: '15%',
  191. align: 'center',
  192. customRender: function (text) {
  193. return text || text == 0 ? text : '--'
  194. }
  195. },
  196. {
  197. title: '单位',
  198. dataIndex: 'productUnit',
  199. width: '15%',
  200. align: 'center',
  201. customRender: function (text) {
  202. return text || '--'
  203. }
  204. },
  205. {
  206. title: '滞销天数',
  207. dataIndex: 'unsalableDays',
  208. width: '15%',
  209. align: 'center',
  210. customRender: function (text) {
  211. return text || text == 0 ? text : '--'
  212. }
  213. },
  214. { title: '调回数量', width: '20%', align: 'center', scopedSlots: { customRender: 'confirmQty' } }
  215. ],
  216. showChecked: false,
  217. rowSelectionInfo: null,
  218. // 加载数据方法 必须为 Promise 对象
  219. loadData: parameter => {
  220. // 获取列表
  221. this.spinning = true
  222. if (!this.checkValueRange()) {
  223. this.spinning = false
  224. return
  225. }
  226. this.queryParam.shelfSn = this.recallBillInfo.shelfSn
  227. return shelfControlList(this.queryParam).then(res => {
  228. let data
  229. if (res.status == 200) {
  230. data = res.data
  231. if (this.showChecked) {
  232. data = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  233. }
  234. for (var i = 0; i < data.length; i++) {
  235. data[i].no = i + 1
  236. const row = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  237. const cur = row.find(item => item.id == data[i].id)
  238. data[i].confirmQty = cur ? cur.confirmQty : (data[i].confirmQty || data[i].qty)
  239. }
  240. }
  241. this.spinning = false
  242. return data
  243. })
  244. }
  245. }
  246. },
  247. methods: {
  248. onSelectChange (obj) {
  249. // 获取选中列表
  250. this.rowSelectionInfo = obj || null
  251. },
  252. // 确定新增回调单
  253. handleSave () {
  254. const _this = this
  255. if (this.rowSelectionInfo.selectedRows && this.rowSelectionInfo.selectedRows.length == 0) {
  256. this.$message.warning('请先选择产品')
  257. return
  258. }
  259. const arr = []
  260. this.rowSelectionInfo.selectedRows.forEach((item, index) => {
  261. if (item.confirmQty) {
  262. arr.push({
  263. shelfSn: item.shelfSn,
  264. shelfPlaceSn: item.shelfPlaceSn,
  265. shelfPlaceCode: item.shelfPlaceCode,
  266. productSn: item.productSn,
  267. productCode: item.productCode,
  268. productName: item.productName,
  269. qty: item.confirmQty
  270. })
  271. }
  272. })
  273. _this.spinning = true
  274. const params = {
  275. shelfSn: this.recallBillInfo.shelfSn,
  276. detailList: arr
  277. }
  278. shelfRecallSave(params).then(res => {
  279. _this.spinning = false
  280. if (res.status == 200) {
  281. _this.$emit('ok')
  282. _this.isShow = false
  283. this.$refs.recallBillTable.clearSelected()
  284. _this.$message.success('保存并确认成功')
  285. }
  286. })
  287. },
  288. isShowChooseList (e) {
  289. this.showChecked = e.target.checked
  290. this.$refs.recallBillTable.refresh(true)
  291. },
  292. // 重置
  293. resetSearchForm () {
  294. const obj = {
  295. // 查询条件
  296. shelfSn: this.recallBillInfo.shelfSn,
  297. productCode: undefined,
  298. productName: undefined,
  299. unsalableDaysBegin: undefined,
  300. unsalableDaysEnd: undefined
  301. }
  302. this.queryParam = obj
  303. this.showChecked = false
  304. this.$refs.recallBillTable.clearSelected()
  305. this.$refs.recallBillTable.refresh(true)
  306. },
  307. // 校验滞销天数数值范围
  308. checkValueRange () {
  309. const isONull = this.queryParam.unsalableDaysBegin === null || this.queryParam.unsalableDaysBegin === undefined
  310. const isOEmpty = this.queryParam.unsalableDaysBegin === ''
  311. const isOZero = this.queryParam.unsalableDaysBegin === 0
  312. const isTNull = this.queryParam.unsalableDaysEnd === null || this.queryParam.unsalableDaysEnd === undefined
  313. const isTEmpty = this.queryParam.unsalableDaysEnd === ''
  314. const isTZero = this.queryParam.unsalableDaysEnd === 0
  315. // 第一个为空(可为null可为空字符)第二个不为空
  316. // 第一个不为空第二个为空(可为null可为空字符)
  317. // 第一个大于第二个
  318. if ((isONull || isOEmpty) && (this.queryParam.unsalableDaysEnd || isTZero)) {
  319. this.$message.info('请输入正确的滞销天数查询范围!')
  320. return false
  321. }
  322. if ((this.queryParam.unsalableDaysBegin || isOZero) && (isTNull || isTEmpty)) {
  323. this.$message.info('请输入正确的滞销天数查询范围!')
  324. return false
  325. }
  326. if (this.queryParam.unsalableDaysBegin > this.queryParam.unsalableDaysEnd) {
  327. this.$message.info('请输入正确的滞销天数查询范围!')
  328. return false
  329. }
  330. this.queryParam.unsalableDaysBegin = this.queryParam.unsalableDaysBegin > 999999999 ? 999999999 : this.queryParam.unsalableDaysBegin
  331. this.queryParam.unsalableDaysEnd = this.queryParam.unsalableDaysEnd > 999999999 ? 999999999 : this.queryParam.unsalableDaysEnd
  332. return true
  333. }
  334. },
  335. watch: {
  336. // 父页面传过来的弹框状态
  337. openModal (newValue, oldValue) {
  338. this.isShow = newValue
  339. },
  340. // 重定义的弹框状态
  341. isShow (newValue, oldValue) {
  342. if (!newValue) {
  343. this.$emit('close')
  344. this.$refs.ruleForm.resetFields()
  345. } else {
  346. this.$nextTick(() => {
  347. this.resetSearchForm()
  348. })
  349. }
  350. }
  351. },
  352. computed: {
  353. totalNum () {
  354. let ret = 0
  355. this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.map(item => {
  356. ret = ret + item.confirmQty
  357. })
  358. return ret
  359. },
  360. totalCategory () {
  361. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.length
  362. }
  363. }
  364. }
  365. </script>
  366. <style lang="less">
  367. .shelfSet-basicInfo-modal {
  368. .ant-modal-body {
  369. padding: 40px 40px 24px;
  370. }
  371. .ant-form-item {
  372. margin-bottom: 15px;
  373. }
  374. .btn-cont {
  375. text-align: center;
  376. margin: 35px 0 10px;
  377. }
  378. .tableSpan {
  379. margin: 0 16px;
  380. span {
  381. margin: 0 10px;
  382. color: red;
  383. font-weight: bold;
  384. }
  385. }
  386. }
  387. </style>