edit.vue 15 KB

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