warehousing.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <div class="purchaseOrderWarehousing-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" @back="handleBack" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="purchaseOrderWarehousing-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <span class="billno">单号:{{ (detail&&detail[0]&&detail[0].purchaseBillNo) ? detail[0].purchaseBillNo : '--' }}</span>
  9. </template>
  10. </a-page-header>
  11. <!-- 内容 -->
  12. <a-card size="small" v-for="(item,bindex) in detail" :key="item.id" :bordered="false" class="purchaseOrderWarehousing-cont">
  13. <!-- 总计 -->
  14. <a-alert type="info" showIcon style="margin-bottom:15px">
  15. <div slot="message" >
  16. <div>产品款数 <strong>{{ item.totalPutCategory }}</strong> ,本次发货数量合计 <strong>{{ item.totalPutQty }}</strong> ,本次发货金额合计¥<strong>{{ item.totalPutAmount }}</strong></div>
  17. </div>
  18. </a-alert>
  19. <!-- 列表 -->
  20. <s-table
  21. class="sTable"
  22. :ref="'table-'+bindex"
  23. size="small"
  24. :rowKey="(record) => record.id"
  25. :columns="columns"
  26. :data="loadData"
  27. :tableId="item.receivingBillSn"
  28. :index="bindex"
  29. :scroll="{ x: 1630 }"
  30. bordered>
  31. <!-- 采购数量 -->
  32. <template slot="origqty" slot-scope="text, record, index">
  33. <div>{{ text }}</div>
  34. <div v-if="record.origqty">原采购数量:{{ record.origqty }}</div>
  35. </template>
  36. <!-- 仓库仓位 -->
  37. <template slot="warehousePosition" slot-scope="text, record, index">
  38. <a-cascader
  39. @change="e => changeWarehouseCascade(e, record, index, bindex)"
  40. v-model="record.warehouseCascade"
  41. :disabled="!(item.auditState=='WAIT_PUT_WAREHOUSE' || item.auditState == 'PUT_WAREHOUSE_AUDIT_REJECT')"
  42. expand-trigger="hover"
  43. :options="warehouseCascadeData"
  44. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  45. id="purchaseOrderWarehousing-warehouseCascade"
  46. placeholder="请选择仓库仓位"
  47. :allowClear="false"
  48. style="width: 100%;" />
  49. </template>
  50. </s-table>
  51. <div style="text-align: center;">
  52. <a-button
  53. type="primary"
  54. class="button-warning"
  55. :id="'purchaseOrderWarehousing-warehousing-'+bindex"
  56. @click="handleWarehousing(item,bindex)"
  57. v-if="item.auditState=='WAIT_PUT_WAREHOUSE' || item.auditState == 'PUT_WAREHOUSE_AUDIT_REJECT'"
  58. >确认入库</a-button>
  59. </div>
  60. </a-card>
  61. </a-spin>
  62. </div>
  63. </template>
  64. <script>
  65. import { STable, VSelect } from '@/components'
  66. import { purchaseWriteStockIn, receivingQuery, receivingDetail } from '@/api/purchase'
  67. import { purchaseUpdateWarehouse } from '@/api/purchaseDetail'
  68. import ProductType from '../../common/productType.js'
  69. import ProductBrand from '../../common/productBrand.js'
  70. import { warehouseCascadeList } from '@/api/warehouse'
  71. export default {
  72. components: { STable, VSelect, ProductType, ProductBrand },
  73. data () {
  74. return {
  75. spinning: false,
  76. detail: null, // 详情数据
  77. productType: [],
  78. queryParam: {
  79. productBrandSn: undefined,
  80. queryWord: '',
  81. brand: '',
  82. productTypeSn1: '', // 产品一级分类
  83. productTypeSn2: '', // 产品二级分类
  84. productTypeSn3: '' // 产品三级分类
  85. },
  86. disabled: false, // 查询、重置按钮是否可操作
  87. warehouseCascadeData: [], // 仓库仓位
  88. // 表头
  89. columns: [
  90. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  91. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  92. { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  93. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '采购单价', dataIndex: 'discountedPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  95. { title: '采购数量', dataIndex: 'qty', width: 100, align: 'center', scopedSlots: { customRender: 'origqty' } },
  96. { title: '本次发货数量', dataIndex: 'shippedQty', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  97. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  98. { title: '本次发货金额', dataIndex: 'discountedAmount', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') }, fixed: 'right' },
  99. { title: '本次入库数量', dataIndex: 'putQty', width: 120, align: 'center', customRender: function (text) { return text || '--' }, fixed: 'right' },
  100. { title: '仓库仓位', scopedSlots: { customRender: 'warehousePosition' }, width: 250, align: 'center', fixed: 'right' }
  101. ],
  102. chooseLoadData: [],
  103. // 加载数据方法 必须为 Promise 对象
  104. loadData: parameter => {
  105. this.disabled = true
  106. this.queryParam.receivingBillSn = parameter.tableId
  107. return receivingDetail(Object.assign(parameter, this.queryParam)).then(res => {
  108. const data = res.data
  109. const no = (data.pageNo - 1) * data.pageSize
  110. for (var i = 0; i < data.list.length; i++) {
  111. data.list[i].no = no + i + 1
  112. data.list[i].shippedQty = data.list[i].putQty
  113. const warehouseSn = data.list[i].warehouseSn || undefined
  114. const warehouseLocationSn = data.list[i].warehouseLocationSn || undefined
  115. if (warehouseSn || warehouseLocationSn) {
  116. data.list[i].warehouseSnBackups = warehouseSn
  117. data.list[i].warehouseLocationSnBackups = warehouseLocationSn
  118. data.list[i].warehouseCascade = [warehouseSn, warehouseLocationSn]
  119. } else {
  120. data.list[i].warehouseCascade = undefined
  121. }
  122. }
  123. this.disabled = false
  124. this.chooseLoadData[parameter.index] = data.list
  125. return data
  126. })
  127. }
  128. }
  129. },
  130. methods: {
  131. // 产品分类 change
  132. changeProductType (val, opt) {
  133. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  134. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  135. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  136. },
  137. // 重置产品库
  138. resetSearchForm () {
  139. this.queryParam = {
  140. productBrandSn: undefined,
  141. productTypeSn1: '', // 产品一级分类
  142. productTypeSn2: '', // 产品二级分类
  143. productTypeSn3: '', // 产品三级分类
  144. queryWord: '',
  145. brand: ''
  146. }
  147. this.productType = []
  148. this.$refs.table.refresh(true)
  149. },
  150. // 判断是否选择了仓库
  151. hasChoseWarehousing (data) {
  152. return data.find(item => !item.warehouseCascade || item.warehouseCascade.length == 0)
  153. },
  154. // 确认入库
  155. handleWarehousing (row, index) {
  156. const list = this.chooseLoadData[index]
  157. if (this.hasChoseWarehousing(list)) {
  158. this.$message.warning('请选择仓库仓位!')
  159. return
  160. }
  161. this.spinning = true
  162. purchaseWriteStockIn({ id: row.id }).then(res => {
  163. if (res.status == 200) {
  164. this.$message.success(res.message)
  165. this.getDetail()
  166. this.spinning = false
  167. } else {
  168. this.spinning = false
  169. }
  170. })
  171. },
  172. // 返回列表
  173. handleBack () {
  174. this.$router.push({ path: '/purchasingManagement/purchaseOrder/list' })
  175. },
  176. filterOption (input, option) {
  177. return (
  178. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  179. )
  180. },
  181. // 详情
  182. getDetail () {
  183. receivingQuery({ purchaseBillSn: this.$route.params.sn }).then(res => {
  184. if (res.status == 200) {
  185. this.detail = res.data
  186. } else {
  187. this.detail = null
  188. }
  189. })
  190. },
  191. // 仓库仓位 级联 列表
  192. getWarehouseCascade () {
  193. warehouseCascadeList({}).then(res => {
  194. if (res.status == 200) {
  195. res.data.map(item => {
  196. item.sn = item.warehouseSn
  197. if (item.warehouseLocationList) {
  198. item.warehouseLocationList.map(subItem => {
  199. subItem.sn = subItem.warehouseLocationSn
  200. })
  201. }
  202. })
  203. this.warehouseCascadeData = res.data
  204. } else {
  205. this.warehouseCascadeData = []
  206. }
  207. })
  208. },
  209. // 修改仓库仓位
  210. changeWarehouseCascade (val, opt, ind, bindex) {
  211. let loadData = this.chooseLoadData[bindex][ind]
  212. if (val.length == 1) {
  213. this.$message.warning('当前仓库无仓位,请选择其他仓库')
  214. const warehouseSnBackups = loadData.warehouseSnBackups || undefined
  215. const warehouseLocationSnBackups = loadData.warehouseLocationSnBackups || undefined
  216. loadData.warehouseSn = warehouseSnBackups
  217. loadData.warehouseLocationSn = warehouseLocationSnBackups
  218. if (warehouseSnBackups || warehouseLocationSnBackups) {
  219. loadData.warehouseCascade = [warehouseSnBackups, warehouseLocationSnBackups]
  220. } else {
  221. loadData.warehouseCascade = undefined
  222. }
  223. } else {
  224. loadData.warehouseSn = val[0] ? val[0] : ''
  225. loadData.warehouseLocationSn = val[1] ? val[1] : ''
  226. loadData.warehouseSnBackups = val[0] ? val[0] : ''
  227. loadData.warehouseLocationSnBackups = val[1] ? val[1] : ''
  228. loadData = this.chooseLoadData[bindex][ind]
  229. this.updateWarehouse(loadData, bindex)
  230. }
  231. },
  232. // 修改仓库
  233. updateWarehouse (row, bindex) {
  234. this.spinning = true
  235. purchaseUpdateWarehouse({
  236. id: row.id,
  237. warehouseSn: row.warehouseSn,
  238. warehouseLocationSn: row.warehouseLocationSn
  239. }).then(res => {
  240. if (res.status == 200) {
  241. this.$message.success(res.message)
  242. console.log(bindex, this.$refs)
  243. this.$refs['table-' + bindex][0].refresh()
  244. this.spinning = false
  245. } else {
  246. this.spinning = false
  247. }
  248. })
  249. }
  250. },
  251. mounted () {
  252. this.getDetail()
  253. this.getWarehouseCascade()
  254. }
  255. }
  256. </script>
  257. <style lang="less">
  258. .purchaseOrderWarehousing-wrap{
  259. .btn-cont {
  260. text-align: center;
  261. margin: 35px 0 10px;
  262. }
  263. .billno{
  264. font-size: 14px;
  265. font-weight: bold;
  266. margin: 0 15px;
  267. }
  268. .purchaseOrderWarehousing-cont{
  269. margin-top: 10px;
  270. }
  271. }
  272. </style>