edit.vue 13 KB

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