edit.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <template>
  2. <div class="warehouseAllocationEdit-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="warehouseAllocationEdit-back" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="warehouseAllocationEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <span style="margin: 0 15px;color: #666;">调出仓库:{{ (basicInfoData&&basicInfoData.outWarehouseName) || '--' }}</span>
  9. <span style="margin: 0 15px;color: #666;">调入仓库:{{ (basicInfoData&&basicInfoData.putWarehouseName) || '--' }}</span>
  10. </template>
  11. </a-page-header>
  12. <!-- 选择产品 -->
  13. <div class="warehouseAllocationEdit-cont">
  14. <a-collapse :activeKey="['1']">
  15. <a-collapse-panel key="1" header="选择产品">
  16. <!-- 筛选条件 -->
  17. <div class="table-page-search-wrapper">
  18. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  19. <a-row :gutter="15">
  20. <a-col :md="6" :sm="24">
  21. <a-form-item label="产品编码" prop="productCode">
  22. <a-input id="warehouseAllocationEdit-productCode" v-model.trim="queryParam.productCode" placeholder="请输入产品编码" allowClear />
  23. </a-form-item>
  24. </a-col>
  25. <a-col :md="6" :sm="24">
  26. <a-form-item label="产品名称" prop="productName">
  27. <a-input id="warehouseAllocationEdit-productName" v-model.trim="queryParam.productName" placeholder="请输入产品名称" allowClear />
  28. </a-form-item>
  29. </a-col>
  30. <a-col :md="6" :sm="24">
  31. <a-form-item label="原厂编码" prop="productOrigCode">
  32. <a-input id="warehouseAllocationEdit-productOrigCode" v-model.trim="queryParam.productOrigCode" placeholder="请输入原厂编码" allowClear />
  33. </a-form-item>
  34. </a-col>
  35. <template v-if="advanced">
  36. <a-col :md="6" :sm="24">
  37. <a-form-model-item label="产品品牌">
  38. <ProductBrand id="warehouseAllocationEdit-brandSn" placeholder="请选择产品品牌" v-model="queryParam.brandSn"></ProductBrand>
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :md="6" :sm="24">
  42. <a-form-model-item label="产品分类">
  43. <ProductType id="warehouseAllocationEdit-productType" placeholder="请选择产品分类" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
  44. </a-form-model-item>
  45. </a-col>
  46. <a-col :md="6" :sm="24">
  47. <a-form-item label="调出仓位" prop="warehouseLocationSn">
  48. <a-select id="warehouseAllocationEdit-warehouseLocationSn" placeholder="请选择" allowClear v-model="queryParam.warehouseLocationSn" style="width: 100%;">
  49. <a-select-option v-for="item in warehouseOutLocData" :key="item.warehouseLocationSn" :value="item.warehouseLocationSn">{{ item.name }}</a-select-option>
  50. </a-select>
  51. </a-form-item>
  52. </a-col>
  53. </template>
  54. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  55. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="warehouseAllocationList-refresh">查询</a-button>
  56. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="warehouseAllocationList-reset">重置</a-button>
  57. <a @click="advanced=!advanced" style="margin-left: 5px">
  58. {{ advanced ? '收起' : '展开' }}
  59. <a-icon :type="advanced ? 'up' : 'down'"/>
  60. </a>
  61. </a-col>
  62. </a-row>
  63. </a-form>
  64. </div>
  65. <!-- 列表 -->
  66. <s-table
  67. class="sTable"
  68. ref="table"
  69. size="small"
  70. :rowKey="(record) => record.stockDetailSn"
  71. rowKeyName="stockDetailSn"
  72. :columns="columns"
  73. @dblclick="handleClickRow"
  74. :data="loadData"
  75. :defaultLoadData="false"
  76. :scroll="{ y: 200 }"
  77. bordered>
  78. <!-- 产品分类 -->
  79. <template slot="productType" slot-scope="text, record">
  80. <span v-if="record.dealerProduct.productTypeName2 || record.dealerProduct.productTypeName3">{{ record.dealerProduct.productTypeName2 }} {{ record.dealerProduct.productTypeName3 ? '>' : '' }} {{ record.dealerProduct.productTypeName3 }}</span>
  81. <span v-else>--</span>
  82. </template>
  83. <!-- 调入仓位 -->
  84. <template slot="putWarehouseLocationSn" slot-scope="text, record">
  85. <div @dblclick.stop>
  86. <a-select size="small" id="warehouseAllocationEdit-putWarehouseLocationSn" placeholder="请选择" v-model="record.putWarehouseLocationSn" style="width: 100%;">
  87. <a-select-option v-for="item in warehousePutLocData" :key="item.warehouseLocationSn" :disabled="item.warehouseLocationSn==record.warehouseLocationSn" :value="item.warehouseLocationSn">{{ item.name }}</a-select-option>
  88. </a-select>
  89. </div>
  90. </template>
  91. <!-- 调出数量 -->
  92. <template slot="outQty" slot-scope="text, record">
  93. <div @dblclick.stop>
  94. <a-input-number
  95. size="small"
  96. id="warehouseAllocationEdit-outQty"
  97. v-model="record.outQty"
  98. :precision="0"
  99. :min="1"
  100. :max="record.currentQty"
  101. placeholder="请输入"
  102. style="width: 100%;" />
  103. </div>
  104. </template>
  105. <!-- 操作 -->
  106. <template slot="action" slot-scope="text, record">
  107. <a-button size="small" type="link" class="button-primary" @click="handleAdd(record)" id="warehouseAllocationEdit-add-btn">添加</a-button>
  108. </template>
  109. </s-table>
  110. </a-collapse-panel>
  111. </a-collapse>
  112. </div>
  113. <!-- 已选产品 -->
  114. <div class="warehouseAllocationEdit-cont">
  115. <a-collapse :activeKey="['1']">
  116. <a-collapse-panel key="1" header="已选产品">
  117. <!-- 总计 -->
  118. <a-alert type="info" style="margin-bottom:10px">
  119. <div slot="message">
  120. 总款数 <strong>{{ (productTotal&&(productTotal.productTotalCategory || productTotal.productTotalCategory==0)) ? productTotal.productTotalCategory : '--' }}</strong> ,
  121. 总数量 <strong>{{ (productTotal&&(productTotal.productTotalQty || productTotal.productTotalQty==0)) ? productTotal.productTotalQty : '--' }}</strong>
  122. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">,总成本 <strong>{{ (productTotal&&(productTotal.productTotalCost || productTotal.productTotalCost==0)) ? toThousands(productTotal.productTotalCost,2) : '--' }}</strong></div>
  123. </div>
  124. </a-alert>
  125. <!-- 筛选条件 -->
  126. <a-row :gutter="15" justify="space-between">
  127. <a-col :span="18">
  128. <div class="table-page-search-wrapper">
  129. <a-form layout="inline" @keyup.enter.native="$refs.chooseTable.refresh(true)">
  130. <a-row :gutter="15">
  131. <a-col :md="9" :sm="24">
  132. <a-form-item label="产品编码" prop="productCode">
  133. <a-input id="warehouseAllocationEdit-productCode" v-model.trim="chooseQueryParam.productCode" placeholder="请输入产品编码" allowClear />
  134. </a-form-item>
  135. </a-col>
  136. <a-col :md="9" :sm="24">
  137. <a-form-item label="产品名称" prop="productName">
  138. <a-input id="warehouseAllocationEdit-productName" v-model.trim="chooseQueryParam.productName" placeholder="请输入产品名称" allowClear />
  139. </a-form-item>
  140. </a-col>
  141. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  142. <a-button type="primary" @click="$refs.chooseTable.refresh(true)" :disabled="chooseDisabled" id="warehouseAllocationList-refresh">查询</a-button>
  143. <a-button style="margin-left: 8px" @click="chooseResetSearchForm" :disabled="chooseDisabled" id="warehouseAllocationList-reset">重置</a-button>
  144. </a-col>
  145. </a-row>
  146. </a-form>
  147. </div>
  148. </a-col>
  149. <a-col :span="6">
  150. <div style="margin-top: 4px;text-align: right;">
  151. <!-- <a-button size="small" style="margin-left: 8px" id="chainTransferOutEdit-import-btn">导入明细</a-button> -->
  152. <a-button size="small" type="danger" style="margin-left: 8px" @click.stop="handleDel('', 'all')" id="warehouseAllocationEdit-del-all-btn">整单删除</a-button>
  153. </div>
  154. </a-col>
  155. </a-row>
  156. <!-- 列表 -->
  157. <s-table
  158. class="sTable"
  159. ref="chooseTable"
  160. size="small"
  161. :rowKey="(record) => record.id"
  162. :columns="chooseColumns"
  163. :data="chooseLoadData"
  164. :defaultLoadData="false"
  165. :scroll="{ y: 300 }"
  166. bordered>
  167. <!-- 产品分类 -->
  168. <template slot="productType" slot-scope="text, record">
  169. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  170. <span v-else>--</span>
  171. </template>
  172. <!-- 调入仓位 -->
  173. <template slot="putWarehouseLocationSn" slot-scope="text, record">
  174. <a-select
  175. size="small"
  176. id="warehouseAllocationEdit-putWarehouseLocationSn"
  177. @change="chooseWarehouseLocChange(record)"
  178. placeholder="请选择"
  179. v-model="record.putWarehouseLocationSn"
  180. style="width: 100%;">
  181. <a-select-option v-for="item in warehousePutLocData" :key="item.warehouseLocationSn" :disabled="item.warehouseLocationSn==record.outWarehouseLocationSn" :value="item.warehouseLocationSn">{{ item.name }}</a-select-option>
  182. </a-select>
  183. </template>
  184. <!-- 调出数量 -->
  185. <template slot="outQty" slot-scope="text, record">
  186. <a-input-number
  187. size="small"
  188. id="warehouseAllocationEdit-outQty"
  189. v-model="record.outQty"
  190. :precision="0"
  191. :min="1"
  192. :max="999999"
  193. placeholder="请输入"
  194. @blur="e => outQtyBlur(e.target.value, record)"
  195. style="width: 100%;" />
  196. </template>
  197. <!-- 操作 -->
  198. <template slot="action" slot-scope="text, record">
  199. <a-button size="small" type="link" class="button-error" @click="handleDel(record)" id="warehouseAllocationEdit-del-btn">删除</a-button>
  200. </template>
  201. </s-table>
  202. </a-collapse-panel>
  203. </a-collapse>
  204. </div>
  205. </a-spin>
  206. <div class="affix-cont">
  207. <a-button
  208. type="primary"
  209. id="warehouseAllocationEdit-submit"
  210. size="large"
  211. :disabled="spinning"
  212. class="button-primary"
  213. @click="handleSubmit"
  214. style="padding: 0 60px;">提交</a-button>
  215. </div>
  216. </div>
  217. </template>
  218. <script>
  219. import { commonMixin } from '@/utils/mixin'
  220. import { STable, VSelect } from '@/components'
  221. import { allocWarehouseDetailList, allocWarehouseDetail, updatePutWhLocation, productQuery, allocWarehouseDetailCount, allocWarehouseDetailSave, allocWarehouseDetailDel, allocWarehouseSubmit } from '@/api/allocWarehouse'
  222. import ProductType from '../../common/productType.js'
  223. import ProductBrand from '../../common/productBrand.js'
  224. import { warehouseLocAllList } from '@/api/warehouse'
  225. export default {
  226. name: 'AllocWarehouseEdit',
  227. components: { STable, VSelect, ProductType, ProductBrand },
  228. mixins: [commonMixin],
  229. data () {
  230. return {
  231. spinning: false,
  232. chooseLoading: false,
  233. queryParam: {
  234. productCode: '',
  235. productName: '',
  236. productOrigCode: '', // 原厂编码
  237. brandSn: undefined,
  238. productTypeSn1: undefined,
  239. productTypeSn2: undefined,
  240. productTypeSn3: undefined,
  241. warehouseLocationSn: undefined // 调出仓位
  242. },
  243. chooseQueryParam: {
  244. productCode: '',
  245. productName: ''
  246. },
  247. disabled: false, // 查询、重置按钮是否可操作
  248. chooseDisabled: false, // 查询、重置按钮是否可操作
  249. advanced: false, // 高级搜索 展开/关闭
  250. productType: [],
  251. warehousePutLocData: [], // 调入仓位 下拉数据
  252. warehouseOutLocData: [], // 调出仓位 下拉数据
  253. // 加载数据方法 必须为 Promise 对象
  254. loadData: parameter => {
  255. this.disabled = true
  256. const params = Object.assign(parameter, this.queryParam)
  257. params.enabledFlag = 1
  258. params.warehouseSn = this.basicInfoData ? this.basicInfoData.outWarehouseSn : ''
  259. return productQuery(params).then(res => {
  260. const data = res.data
  261. const no = (data.pageNo - 1) * data.pageSize
  262. for (var i = 0; i < data.list.length; i++) {
  263. data.list[i].no = no + i + 1
  264. }
  265. this.disabled = false
  266. return data
  267. })
  268. },
  269. // 加载数据方法 必须为 Promise 对象
  270. chooseLoadData: parameter => {
  271. this.chooseDisabled = true
  272. const params = Object.assign(parameter, this.chooseQueryParam, { allocationWarehouseSn: this.$route.params.sn })
  273. return allocWarehouseDetailList(params).then(res => {
  274. this.getDetailCount(Object.assign(params, this.chooseQueryParam))
  275. const data = res.data
  276. const no = (data.pageNo - 1) * data.pageSize
  277. for (var i = 0; i < data.list.length; i++) {
  278. data.list[i].no = no + i + 1
  279. data.list[i].outQty = data.list[i].allocationQty
  280. data.list[i].outQtyBackups = data.list[i].allocationQty
  281. data.list[i].allocationCost = data.list[i].totalAllocationCost / data.list[i].allocationQty
  282. }
  283. this.chooseDisabled = false
  284. return data
  285. })
  286. },
  287. basicInfoData: null, // 基本信息
  288. productTotal: null // 合计
  289. }
  290. },
  291. computed: {
  292. columns () {
  293. const _this = this
  294. const arr = [
  295. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  296. { title: '产品编码', dataIndex: 'productCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  297. { title: '产品名称', dataIndex: 'productName', width: '17%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  298. { title: '原厂编码', dataIndex: 'productOrigCode', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  299. { title: '品牌', dataIndex: 'brandName', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  300. { title: '分类', scopedSlots: { customRender: 'productType' }, width: '9%', align: 'center' },
  301. { title: '调出仓位', dataIndex: 'warehouseLocationName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  302. { title: '调入仓位', scopedSlots: { customRender: 'putWarehouseLocationSn' }, width: '8%', align: 'center' },
  303. { title: '调出数量', scopedSlots: { customRender: 'outQty' }, width: '7%', align: 'center' },
  304. { title: '可用库存数', dataIndex: 'currentQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  305. // { title: '冻结库存数', dataIndex: 'freezeQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  306. { title: '单位', dataIndex: 'unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  307. { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
  308. ]
  309. if (this.$hasPermissions('M_ShowAllCost')) {
  310. arr.splice(6, 0, { title: '成本价', dataIndex: 'putCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  311. }
  312. return arr
  313. },
  314. chooseColumns () {
  315. const _this = this
  316. const arr = [
  317. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  318. { title: '产品编码', dataIndex: 'productCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  319. { title: '产品名称', dataIndex: 'productName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  320. { title: '原厂编码', dataIndex: 'productOrigCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  321. { title: '品牌', dataIndex: 'brandName', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  322. { title: '分类', scopedSlots: { customRender: 'productType' }, width: '9%', align: 'center' },
  323. { title: '调出仓位', dataIndex: 'outWarehouseLocationName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  324. { title: '调入仓位', scopedSlots: { customRender: 'putWarehouseLocationSn' }, width: '8%', align: 'center' },
  325. { title: '调出数量', scopedSlots: { customRender: 'outQty' }, width: '8%', align: 'center' },
  326. { title: '单位', dataIndex: 'productUnit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  327. { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
  328. ]
  329. if (this.$hasPermissions('M_ShowAllCost')) {
  330. arr.splice(6, 0, { title: '成本价', dataIndex: 'allocationCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  331. arr.splice(11, 0, { title: '成本小计', dataIndex: 'totalAllocationCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  332. }
  333. return arr
  334. }
  335. },
  336. methods: {
  337. // 重置
  338. resetSearchForm () {
  339. this.queryParam.productCode = ''
  340. this.queryParam.productName = ''
  341. this.queryParam.productOrigCode = ''
  342. this.queryParam.brandSn = undefined
  343. this.queryParam.productTypeSn1 = undefined
  344. this.queryParam.productTypeSn2 = undefined
  345. this.queryParam.productTypeSn3 = undefined
  346. this.queryParam.warehouseLocationSn = undefined
  347. this.productType = []
  348. this.$refs.table.refresh(true)
  349. },
  350. // 双击快速添加
  351. handleClickRow (record) {
  352. this.handleAdd(record)
  353. },
  354. // 已选产品 重置
  355. chooseResetSearchForm () {
  356. this.chooseQueryParam.productCode = ''
  357. this.chooseQueryParam.productName = ''
  358. this.$refs.chooseTable.refresh(true)
  359. },
  360. // 基本信息
  361. getDetail () {
  362. this.disabled = true
  363. allocWarehouseDetail({ id: this.$route.params.id }).then(res => {
  364. if (res.status == 200) {
  365. this.basicInfoData = res.data
  366. this.resetSearchForm()
  367. this.getWarehouseLoc(res.data.putWarehouseSn, 'put')
  368. this.getWarehouseLoc(res.data.outWarehouseSn, 'out')
  369. } else {
  370. this.basicInfoData = null
  371. }
  372. this.disabled = false
  373. })
  374. },
  375. // 添加/编辑
  376. handleAdd (row, isEdit) {
  377. if (!isEdit && !row.putWarehouseLocationSn) {
  378. this.$message.warning('请选择调入仓位后再添加!')
  379. return
  380. }
  381. if (!isEdit && !row.outQty) {
  382. this.$message.warning('请输入调出数量后再添加!')
  383. return
  384. }
  385. const params = {
  386. id: isEdit ? row.id : undefined,
  387. allocationWarehouseSn: this.$route.params.sn,
  388. allocationCost: isEdit ? row.allocationCost : row.putCost,
  389. allocationQty: row.outQty,
  390. brandSn: row.brandSn,
  391. outWarehouseLocationSn: isEdit ? row.outWarehouseLocationSn : row.warehouseLocationSn,
  392. productCode: row.productCode,
  393. productOrigCode: row.productOrigCode || undefined,
  394. productSn: row.productSn,
  395. productTypeSn1: row.productTypeSn1,
  396. productTypeSn2: row.productTypeSn2,
  397. productTypeSn3: row.productTypeSn3,
  398. putWarehouseLocationSn: row.putWarehouseLocationSn
  399. }
  400. if (isEdit) { // 编辑
  401. // 清空数量时,值应保持未清空前的值,因数量不可为空
  402. if (!row.outQty) {
  403. row.outQty = row.outQtyBackups
  404. return
  405. }
  406. }
  407. this.spinning = true
  408. allocWarehouseDetailSave(params).then(res => {
  409. if (res.status == 200) {
  410. this.$message.success(res.message)
  411. if (isEdit) {
  412. this.$refs.table.refresh()
  413. }
  414. this.$refs.chooseTable.refresh()
  415. this.spinning = false
  416. } else {
  417. this.spinning = false
  418. row.outQty = row.outQtyBackups
  419. }
  420. })
  421. },
  422. // 删除
  423. handleDel (row, isAll) {
  424. const _this = this
  425. const content = isAll ? '删除后不可恢复,确定要进行整单删除吗?' : '删除后不可恢复,确定要进行删除吗?'
  426. this.$confirm({
  427. title: '提示',
  428. content: content,
  429. centered: true,
  430. onOk () {
  431. let params
  432. if (isAll) { // 整单删除
  433. params = { allocationWarehouseSn: _this.$route.params.sn }
  434. } else { // 单个删除
  435. params = {
  436. allocationWarehouseSn: _this.$route.params.sn,
  437. productSn: row.productSn,
  438. outWarehouseLocationSn: row.outWarehouseLocationSn,
  439. putWarehouseLocationSn: row.putWarehouseLocationSn
  440. }
  441. }
  442. _this.spinning = true
  443. allocWarehouseDetailDel(params).then(res => {
  444. if (res.status == 200) {
  445. _this.$message.success(res.message)
  446. _this.$refs.table.refresh()
  447. _this.$refs.chooseTable.refresh()
  448. _this.spinning = false
  449. } else {
  450. _this.spinning = false
  451. }
  452. })
  453. }
  454. })
  455. },
  456. // 提交
  457. handleSubmit () {
  458. const _this = this
  459. _this.spinning = true
  460. allocWarehouseSubmit({ id: this.$route.params.id }).then(res => {
  461. if (res.status == 200) {
  462. this.$message.success(res.message)
  463. setTimeout(() => {
  464. _this.handleBack()
  465. _this.spinning = false
  466. }, 1000)
  467. } else {
  468. _this.spinning = false
  469. }
  470. })
  471. },
  472. // 合计
  473. getDetailCount (params) {
  474. allocWarehouseDetailCount(params).then(res => {
  475. if (res.status == 200) {
  476. this.productTotal = res.data
  477. } else {
  478. this.productTotal = null
  479. }
  480. })
  481. },
  482. // 返回列表
  483. handleBack () {
  484. this.$router.push({ path: '/allocationManagement/warehouseAllocation/list' })
  485. },
  486. // 已选产品 调出数量 blur
  487. outQtyBlur (val, record) {
  488. // 光标移出,值发生改变再调用编辑接口
  489. if (val != record.outQtyBackups) {
  490. this.handleAdd(record, 'edit')
  491. }
  492. },
  493. // 已选产品 仓位 change
  494. chooseWarehouseLocChange (row) {
  495. const params = {
  496. allocationWarehouseSn: this.$route.params.sn,
  497. productSn: row.productSn,
  498. outWarehouseLocationSn: row.outWarehouseLocationSn,
  499. putWarehouseLocationSn: row.putWarehouseLocationSn
  500. }
  501. this.spinning = true
  502. updatePutWhLocation(params).then(res => {
  503. if (res.status == 200) {
  504. this.$message.success(res.message)
  505. this.$refs.table.refresh()
  506. this.$refs.chooseTable.refresh()
  507. this.spinning = false
  508. } else {
  509. this.spinning = false
  510. }
  511. })
  512. },
  513. // 产品分类 change
  514. changeProductType (val, opt) {
  515. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  516. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  517. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  518. },
  519. // 获取仓库仓位
  520. getWarehouseLoc (sn, type) {
  521. warehouseLocAllList({ warehouseSn: sn }).then(res => {
  522. if (type == 'put') {
  523. this.warehousePutLocData = res.data || []
  524. } else if (type == 'out') {
  525. this.warehouseOutLocData = res.data || []
  526. }
  527. })
  528. },
  529. pageInit () {
  530. this.chooseResetSearchForm()
  531. this.getDetail()
  532. }
  533. },
  534. mounted () {
  535. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  536. this.pageInit()
  537. }
  538. },
  539. activated () {
  540. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  541. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  542. this.pageInit()
  543. }
  544. },
  545. beforeRouteEnter (to, from, next) {
  546. next(vm => {})
  547. }
  548. }
  549. </script>
  550. <style lang="less">
  551. .warehouseAllocationEdit-wrap{
  552. position: relative;
  553. height: 100%;
  554. padding-bottom: 51px;
  555. box-sizing: border-box;
  556. .warehouseAllocationEdit-back, .warehouseAllocationEdit-cont{
  557. margin-bottom: 10px;
  558. }
  559. >.ant-spin-nested-loading{
  560. overflow-y: auto;
  561. height: 100%;
  562. }
  563. }
  564. </style>