warehousing.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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" style="margin-bottom:10px">
  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: 1280 }"
  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. size="small"
  40. @change="e => changeWarehouseCascade(e, record, index, bindex)"
  41. v-model="record.warehouseCascade"
  42. :disabled="!(item.auditState=='WAIT_PUT_WAREHOUSE' || item.auditState == 'PUT_WAREHOUSE_AUDIT_REJECT')"
  43. expand-trigger="hover"
  44. :options="warehouseCascadeData"
  45. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  46. id="purchaseOrderWarehousing-warehouseCascade"
  47. placeholder="请选择仓库仓位"
  48. :allowClear="false"
  49. style="width: 100%;" />
  50. </template>
  51. </s-table>
  52. <div style="text-align: center;">
  53. <a-button
  54. type="primary"
  55. class="button-warning"
  56. :id="'purchaseOrderWarehousing-warehousing-'+bindex"
  57. @click="handleWarehousing(item,bindex)"
  58. v-if="item.auditState=='WAIT_PUT_WAREHOUSE' || item.auditState == 'PUT_WAREHOUSE_AUDIT_REJECT'"
  59. >确认入库</a-button>
  60. </div>
  61. </a-card>
  62. </a-spin>
  63. </div>
  64. </template>
  65. <script>
  66. import { STable, VSelect } from '@/components'
  67. import { purchaseWriteStockIn, receivingQuery, receivingDetail } from '@/api/purchase'
  68. import { purchaseUpdateWarehouse } from '@/api/purchaseDetail'
  69. import ProductType from '../../common/productType.js'
  70. import ProductBrand from '../../common/productBrand.js'
  71. import { warehouseCascadeList } from '@/api/warehouse'
  72. export default {
  73. components: { STable, VSelect, ProductType, ProductBrand },
  74. data () {
  75. return {
  76. spinning: false,
  77. detail: null, // 详情数据
  78. productType: [],
  79. queryParam: {
  80. productBrandSn: undefined,
  81. queryWord: '',
  82. brand: '',
  83. productTypeSn1: '', // 产品一级分类
  84. productTypeSn2: '', // 产品二级分类
  85. productTypeSn3: '' // 产品三级分类
  86. },
  87. disabled: false, // 查询、重置按钮是否可操作
  88. warehouseCascadeData: [], // 仓库仓位
  89. defaultWarehouseCascade: [], // 默认仓库仓位
  90. // 表头
  91. columns: [
  92. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  93. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  95. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  96. { title: '采购单价', dataIndex: 'discountedPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  97. { title: '采购数量', dataIndex: 'qty', width: 80, align: 'center', scopedSlots: { customRender: 'origqty' } },
  98. { title: '本次发货数量', dataIndex: 'shippedQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  99. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  100. { title: '本次发货金额', dataIndex: 'discountedAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') }, fixed: 'right' },
  101. { title: '本次入库数量', dataIndex: 'putQty', width: 100, align: 'center', customRender: function (text) { return text || '--' }, fixed: 'right' },
  102. { title: '仓库仓位', scopedSlots: { customRender: 'warehousePosition' }, width: 150, align: 'center', fixed: 'right' }
  103. ],
  104. chooseLoadData: [],
  105. // 加载数据方法 必须为 Promise 对象
  106. loadData: parameter => {
  107. this.disabled = true
  108. this.queryParam.receivingBillSn = parameter.tableId
  109. return receivingDetail(Object.assign(parameter, this.queryParam)).then(res => {
  110. const data = res.data
  111. const no = (data.pageNo - 1) * data.pageSize
  112. for (var i = 0; i < data.list.length; i++) {
  113. data.list[i].no = no + i + 1
  114. data.list[i].shippedQty = data.list[i].putQty
  115. const warehouseSn = data.list[i].warehouseSn || undefined
  116. const warehouseLocationSn = data.list[i].warehouseLocationSn || undefined
  117. if (warehouseSn || warehouseLocationSn) {
  118. data.list[i].warehouseSnBackups = warehouseSn
  119. data.list[i].warehouseLocationSnBackups = warehouseLocationSn
  120. data.list[i].warehouseCascade = [warehouseSn, warehouseLocationSn]
  121. } else {
  122. // 设置默认仓库
  123. if (this.defaultWarehouseCascade.length > 0) {
  124. data.list[i].warehouseCascade = this.defaultWarehouseCascade
  125. data.list[i].warehouseSn = this.defaultWarehouseCascade[0]
  126. data.list[i].warehouseLocationSn = this.defaultWarehouseCascade[1]
  127. } else {
  128. data.list[i].warehouseCascade = undefined
  129. }
  130. }
  131. }
  132. this.disabled = false
  133. this.chooseLoadData[parameter.index] = data.list
  134. return data
  135. })
  136. }
  137. }
  138. },
  139. methods: {
  140. // 产品分类 change
  141. changeProductType (val, opt) {
  142. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  143. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  144. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  145. },
  146. // 重置产品库
  147. resetSearchForm () {
  148. this.queryParam = {
  149. productBrandSn: undefined,
  150. productTypeSn1: '', // 产品一级分类
  151. productTypeSn2: '', // 产品二级分类
  152. productTypeSn3: '', // 产品三级分类
  153. queryWord: '',
  154. brand: ''
  155. }
  156. this.productType = []
  157. this.$refs.table.refresh(true)
  158. },
  159. // 判断是否选择了仓库
  160. hasChoseWarehousing (data) {
  161. return data.find(item => !item.warehouseCascade || item.warehouseCascade.length == 0)
  162. },
  163. // 确认入库
  164. handleWarehousing (row, index) {
  165. const list = this.chooseLoadData[index]
  166. if (this.hasChoseWarehousing(list)) {
  167. this.$message.warning('请选择仓库仓位!')
  168. return
  169. }
  170. this.spinning = true
  171. purchaseWriteStockIn({ id: row.id }).then(res => {
  172. if (res.status == 200) {
  173. this.$message.success(res.message)
  174. this.getDetail()
  175. this.spinning = false
  176. } else {
  177. this.spinning = false
  178. }
  179. })
  180. },
  181. // 返回列表
  182. handleBack () {
  183. this.$router.push({ path: '/purchasingManagement/purchaseOrder/list', query: { closeLastOldTab: true } })
  184. },
  185. filterOption (input, option) {
  186. return (
  187. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  188. )
  189. },
  190. // 详情
  191. getDetail () {
  192. receivingQuery({ purchaseBillSn: this.$route.params.sn }).then(res => {
  193. if (res.status == 200) {
  194. this.detail = res.data
  195. } else {
  196. this.detail = null
  197. }
  198. })
  199. },
  200. // 仓库仓位 级联 列表
  201. getWarehouseCascade () {
  202. const _this = this
  203. warehouseCascadeList({}).then(res => {
  204. if (res.status == 200) {
  205. res.data.filter(item => {
  206. // 过滤默认仓库
  207. if (item.defaultFlag == 1 && item.wasteFlag == 0) { // defaultFlag为1,且不是废品仓
  208. _this.defaultWarehouseCascade[0] = item.warehouseSn
  209. // 过滤默认仓位
  210. item.warehouseLocationList.filter(subItem => {
  211. if (subItem.defaultFlag == 1 && subItem.wasteFlag == 0) {
  212. _this.defaultWarehouseCascade[1] = subItem.warehouseLocationSn
  213. if (_this.detail && _this.detail.length > 0) {
  214. _this.detail.map((k, i) => {
  215. _this.$refs['table-' + i][0].refresh(true)
  216. })
  217. }
  218. }
  219. })
  220. }
  221. })
  222. res.data.map(item => {
  223. item.sn = item.warehouseSn
  224. if (item.warehouseLocationList) {
  225. item.warehouseLocationList.map(subItem => {
  226. subItem.sn = subItem.warehouseLocationSn
  227. })
  228. }
  229. })
  230. this.warehouseCascadeData = res.data
  231. } else {
  232. this.warehouseCascadeData = []
  233. }
  234. })
  235. },
  236. // 修改仓库仓位
  237. changeWarehouseCascade (val, opt, ind, bindex) {
  238. let loadData = this.chooseLoadData[bindex][ind]
  239. if (val.length == 1) {
  240. this.$message.warning('当前仓库无仓位,请选择其他仓库')
  241. const warehouseSnBackups = loadData.warehouseSnBackups || undefined
  242. const warehouseLocationSnBackups = loadData.warehouseLocationSnBackups || undefined
  243. loadData.warehouseSn = warehouseSnBackups
  244. loadData.warehouseLocationSn = warehouseLocationSnBackups
  245. if (warehouseSnBackups || warehouseLocationSnBackups) {
  246. loadData.warehouseCascade = [warehouseSnBackups, warehouseLocationSnBackups]
  247. } else {
  248. loadData.warehouseCascade = undefined
  249. }
  250. } else {
  251. loadData.warehouseSn = val[0] ? val[0] : ''
  252. loadData.warehouseLocationSn = val[1] ? val[1] : ''
  253. loadData.warehouseSnBackups = val[0] ? val[0] : ''
  254. loadData.warehouseLocationSnBackups = val[1] ? val[1] : ''
  255. loadData = this.chooseLoadData[bindex][ind]
  256. this.updateWarehouse(loadData, bindex)
  257. }
  258. },
  259. // 修改仓库
  260. updateWarehouse (row, bindex) {
  261. this.spinning = true
  262. purchaseUpdateWarehouse({
  263. id: row.id,
  264. warehouseSn: row.warehouseSn,
  265. warehouseLocationSn: row.warehouseLocationSn
  266. }).then(res => {
  267. if (res.status == 200) {
  268. this.$message.success(res.message)
  269. console.log(bindex, this.$refs)
  270. this.$refs['table-' + bindex][0].refresh()
  271. this.spinning = false
  272. } else {
  273. this.spinning = false
  274. }
  275. })
  276. }
  277. },
  278. mounted () {
  279. this.getDetail()
  280. this.getWarehouseCascade()
  281. },
  282. beforeRouteEnter (to, from, next) {
  283. next(vm => {
  284. if (!vm.disabled) {
  285. vm.getDetail()
  286. vm.getWarehouseCascade()
  287. }
  288. })
  289. }
  290. }
  291. </script>
  292. <style lang="less">
  293. .purchaseOrderWarehousing-wrap{
  294. position: relative;
  295. height: 100%;
  296. >.ant-spin-nested-loading{
  297. overflow-y: scroll;
  298. height: 100%;
  299. }
  300. .btn-cont {
  301. text-align: center;
  302. margin: 35px 0 10px;
  303. }
  304. .billno{
  305. font-size: 14px;
  306. font-weight: bold;
  307. margin: 0 15px;
  308. }
  309. .purchaseOrderWarehousing-cont{
  310. margin-top: 10px;
  311. }
  312. }
  313. </style>