warehousing.vue 10 KB

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