edit.vue 16 KB

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