edit.vue 13 KB

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