edit.vue 17 KB

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