edit.vue 17 KB

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