edit.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  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
  152. type="danger"
  153. ghost
  154. size="small"
  155. @click="openGuideModal=true"
  156. style="margin-right: 5px"
  157. id="chainTransferOutEdit-import-btn">产品导入</a-button>
  158. <a-button
  159. size="small"
  160. type="danger"
  161. style="margin-left: 8px"
  162. @click.stop="handleDel('', 'all')"
  163. :disabled="chooseLoadDataSource.length==0"
  164. id="warehouseAllocationEdit-del-all-btn">清空列表</a-button>
  165. </div>
  166. </a-col>
  167. </a-row>
  168. <!-- 列表 -->
  169. <s-table
  170. class="sTable"
  171. ref="chooseTable"
  172. size="small"
  173. :rowKey="(record) => record.id"
  174. :columns="chooseColumns"
  175. :data="chooseLoadData"
  176. :defaultLoadData="false"
  177. :scroll="{ y: 300 }"
  178. bordered>
  179. <!-- 产品分类 -->
  180. <template slot="productType" slot-scope="text, record">
  181. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  182. <span v-else>--</span>
  183. </template>
  184. <!-- 调入仓位 -->
  185. <template slot="putWarehouseLocationSn" slot-scope="text, record">
  186. <a-select
  187. size="small"
  188. id="warehouseAllocationEdit-putWarehouseLocationSn"
  189. @change="chooseWarehouseLocChange(record)"
  190. placeholder="请选择"
  191. v-model="record.putWarehouseLocationSn"
  192. style="width: 100%;">
  193. <a-select-option v-for="item in warehousePutLocData" :key="item.warehouseLocationSn" :disabled="item.warehouseLocationSn==record.outWarehouseLocationSn" :value="item.warehouseLocationSn">{{ item.name }}</a-select-option>
  194. </a-select>
  195. </template>
  196. <!-- 调出数量 -->
  197. <template slot="outQty" slot-scope="text, record">
  198. <a-input-number
  199. size="small"
  200. id="warehouseAllocationEdit-outQty"
  201. v-model="record.outQty"
  202. :precision="0"
  203. :min="1"
  204. :max="999999"
  205. placeholder="请输入"
  206. @blur="e => outQtyBlur(e.target.value, record)"
  207. style="width: 100%;" />
  208. </template>
  209. <!-- 操作 -->
  210. <template slot="action" slot-scope="text, record">
  211. <a-button size="small" type="link" class="button-error" @click="handleDel(record)" id="warehouseAllocationEdit-del-btn">删除</a-button>
  212. </template>
  213. </s-table>
  214. </a-collapse-panel>
  215. </a-collapse>
  216. </div>
  217. </a-spin>
  218. <div class="affix-cont">
  219. <a-button
  220. type="primary"
  221. id="warehouseAllocationEdit-submit"
  222. size="large"
  223. :disabled="spinning"
  224. class="button-primary"
  225. @click="handleSubmit"
  226. style="padding: 0 60px;">提交</a-button>
  227. </div>
  228. <!-- 导入产品 -->
  229. <importGuideModal :openModal="openGuideModal" :params="{allocationWarehouseSn: $route.params.sn}" @close="openGuideModal=false" @ok="resetSearchForm" />
  230. </div>
  231. </template>
  232. <script>
  233. import { commonMixin } from '@/utils/mixin'
  234. import { STable, VSelect } from '@/components'
  235. import { allocWarehouseDetailList, allocWarehouseDetail, updatePutWhLocation, productQuery, allocWarehouseDetailCount, allocWarehouseDetailSave, allocWarehouseDetailDel, allocWarehouseSubmit, importProductInsertBatch } from '@/api/allocWarehouse'
  236. import ProductType from '../../common/productType.js'
  237. import ProductBrand from '../../common/productBrand.js'
  238. import { warehouseLocAllList } from '@/api/warehouse'
  239. import importGuideModal from './importGuideModal.vue'
  240. export default {
  241. name: 'AllocWarehouseEdit',
  242. components: { STable, VSelect, ProductType, ProductBrand, importGuideModal },
  243. mixins: [commonMixin],
  244. data () {
  245. return {
  246. spinning: false,
  247. chooseLoading: false,
  248. queryParam: {
  249. productCode: '',
  250. productName: '',
  251. productOrigCode: '', // 原厂编码
  252. brandSn: undefined,
  253. productTypeSn1: undefined,
  254. productTypeSn2: undefined,
  255. productTypeSn3: undefined,
  256. warehouseLocationSn: undefined // 调出仓位
  257. },
  258. chooseQueryParam: {
  259. productCode: '',
  260. productName: ''
  261. },
  262. openGuideModal: false, // 产品导入
  263. disabled: false, // 查询、重置按钮是否可操作
  264. chooseDisabled: false, // 查询、重置按钮是否可操作
  265. advanced: false, // 高级搜索 展开/关闭
  266. productType: [],
  267. warehousePutLocData: [], // 调入仓位 下拉数据
  268. warehouseOutLocData: [], // 调出仓位 下拉数据
  269. chooseLoadDataSource: [],
  270. // 加载数据方法 必须为 Promise 对象
  271. loadData: parameter => {
  272. this.disabled = true
  273. const params = Object.assign(parameter, this.queryParam)
  274. params.enabledFlag = 1
  275. params.warehouseSn = this.basicInfoData ? this.basicInfoData.outWarehouseSn : ''
  276. return productQuery(params).then(res => {
  277. const data = res.data
  278. const no = (data.pageNo - 1) * data.pageSize
  279. for (var i = 0; i < data.list.length; i++) {
  280. data.list[i].no = no + i + 1
  281. }
  282. this.disabled = false
  283. return data
  284. })
  285. },
  286. // 加载数据方法 必须为 Promise 对象
  287. chooseLoadData: parameter => {
  288. this.chooseDisabled = true
  289. const params = Object.assign(parameter, this.chooseQueryParam, { allocationWarehouseSn: this.$route.params.sn })
  290. return allocWarehouseDetailList(params).then(res => {
  291. this.getDetailCount(Object.assign(params, this.chooseQueryParam))
  292. const data = res.data
  293. const no = (data.pageNo - 1) * data.pageSize
  294. for (var i = 0; i < data.list.length; i++) {
  295. data.list[i].no = no + i + 1
  296. data.list[i].outQty = data.list[i].allocationQty
  297. data.list[i].outQtyBackups = data.list[i].allocationQty
  298. data.list[i].allocationCost = data.list[i].totalAllocationCost / data.list[i].allocationQty
  299. }
  300. this.chooseDisabled = false
  301. this.chooseLoadDataSource = data.list
  302. return data
  303. })
  304. },
  305. basicInfoData: null, // 基本信息
  306. productTotal: null // 合计
  307. }
  308. },
  309. computed: {
  310. columns () {
  311. const _this = this
  312. const arr = [
  313. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  314. { title: '产品编码', dataIndex: 'productCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  315. { title: '产品名称', dataIndex: 'productName', width: '17%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  316. { title: '原厂编码', dataIndex: 'productOrigCode', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  317. { title: '品牌', dataIndex: 'brandName', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  318. { title: '分类', scopedSlots: { customRender: 'productType' }, width: '9%', align: 'center' },
  319. { title: '调出仓位', dataIndex: 'warehouseLocationName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  320. { title: '调入仓位', scopedSlots: { customRender: 'putWarehouseLocationSn' }, width: '8%', align: 'center' },
  321. { title: '调出数量', scopedSlots: { customRender: 'outQty' }, width: '7%', align: 'center' },
  322. { title: '可用库存数', dataIndex: 'currentQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  323. // { title: '冻结库存数', dataIndex: 'freezeQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  324. { title: '单位', dataIndex: 'unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  325. { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
  326. ]
  327. if (this.$hasPermissions('M_ShowAllCost')) {
  328. arr.splice(6, 0, { title: '成本价', dataIndex: 'putCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  329. }
  330. return arr
  331. },
  332. chooseColumns () {
  333. const _this = this
  334. const arr = [
  335. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  336. { title: '产品编码', dataIndex: 'productCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  337. { title: '产品名称', dataIndex: 'productName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  338. { title: '原厂编码', dataIndex: 'productOrigCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  339. { title: '品牌', dataIndex: 'brandName', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  340. { title: '分类', scopedSlots: { customRender: 'productType' }, width: '9%', align: 'center' },
  341. { title: '调出仓位', dataIndex: 'outWarehouseLocationName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  342. { title: '调入仓位', scopedSlots: { customRender: 'putWarehouseLocationSn' }, width: '8%', align: 'center' },
  343. { title: '调出数量', scopedSlots: { customRender: 'outQty' }, width: '8%', align: 'center' },
  344. { title: '单位', dataIndex: 'productUnit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  345. { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
  346. ]
  347. if (this.$hasPermissions('M_ShowAllCost')) {
  348. arr.splice(6, 0, { title: '成本价', dataIndex: 'allocationCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  349. arr.splice(11, 0, { title: '成本小计', dataIndex: 'totalAllocationCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  350. }
  351. return arr
  352. }
  353. },
  354. methods: {
  355. // 重置
  356. resetSearchForm () {
  357. this.queryParam.productCode = ''
  358. this.queryParam.productName = ''
  359. this.queryParam.productOrigCode = ''
  360. this.queryParam.brandSn = undefined
  361. this.queryParam.productTypeSn1 = undefined
  362. this.queryParam.productTypeSn2 = undefined
  363. this.queryParam.productTypeSn3 = undefined
  364. this.queryParam.warehouseLocationSn = undefined
  365. this.productType = []
  366. this.$refs.table.refresh(true)
  367. },
  368. // 双击快速添加
  369. handleClickRow (record) {
  370. this.handleAdd(record)
  371. },
  372. // 已选产品 重置
  373. chooseResetSearchForm () {
  374. this.chooseQueryParam.productCode = ''
  375. this.chooseQueryParam.productName = ''
  376. this.$refs.chooseTable.refresh(true)
  377. },
  378. // 基本信息
  379. getDetail () {
  380. this.disabled = true
  381. allocWarehouseDetail({ id: this.$route.params.id }).then(res => {
  382. if (res.status == 200) {
  383. this.basicInfoData = res.data
  384. this.resetSearchForm()
  385. this.getWarehouseLoc(res.data.putWarehouseSn, 'put')
  386. this.getWarehouseLoc(res.data.outWarehouseSn, 'out')
  387. } else {
  388. this.basicInfoData = null
  389. }
  390. this.disabled = false
  391. })
  392. },
  393. // 添加/编辑
  394. handleAdd (row, isEdit) {
  395. if (!isEdit && !row.putWarehouseLocationSn) {
  396. this.$message.warning('请选择调入仓位后再添加!')
  397. return
  398. }
  399. if (!isEdit && !row.outQty) {
  400. this.$message.warning('请输入调出数量后再添加!')
  401. return
  402. }
  403. const params = {
  404. id: isEdit ? row.id : undefined,
  405. allocationWarehouseSn: this.$route.params.sn,
  406. allocationCost: isEdit ? row.allocationCost : row.putCost,
  407. allocationQty: row.outQty,
  408. brandSn: row.brandSn,
  409. outWarehouseLocationSn: isEdit ? row.outWarehouseLocationSn : row.warehouseLocationSn,
  410. productCode: row.productCode,
  411. productOrigCode: row.productOrigCode || undefined,
  412. productSn: row.productSn,
  413. productTypeSn1: row.productTypeSn1,
  414. productTypeSn2: row.productTypeSn2,
  415. productTypeSn3: row.productTypeSn3,
  416. putWarehouseLocationSn: row.putWarehouseLocationSn
  417. }
  418. if (isEdit) { // 编辑
  419. // 清空数量时,值应保持未清空前的值,因数量不可为空
  420. if (!row.outQty) {
  421. row.outQty = row.outQtyBackups
  422. return
  423. }
  424. }
  425. this.spinning = true
  426. allocWarehouseDetailSave(params).then(res => {
  427. if (res.status == 200) {
  428. this.$message.success(res.message)
  429. if (isEdit) {
  430. this.$refs.table.refresh()
  431. }
  432. this.$refs.chooseTable.refresh()
  433. this.spinning = false
  434. } else {
  435. this.spinning = false
  436. row.outQty = row.outQtyBackups
  437. }
  438. })
  439. },
  440. // 删除
  441. handleDel (row, isAll) {
  442. const _this = this
  443. const content = isAll ? '删除后不可恢复,确定要清空列表吗?' : '删除后不可恢复,确定要进行删除吗?'
  444. this.$confirm({
  445. title: '提示',
  446. content: content,
  447. centered: true,
  448. onOk () {
  449. let params
  450. if (isAll) { // 清空列表
  451. params = { allocationWarehouseSn: _this.$route.params.sn }
  452. } else { // 单个删除
  453. params = {
  454. allocationWarehouseSn: _this.$route.params.sn,
  455. productSn: row.productSn,
  456. outWarehouseLocationSn: row.outWarehouseLocationSn,
  457. putWarehouseLocationSn: row.putWarehouseLocationSn
  458. }
  459. }
  460. _this.spinning = true
  461. allocWarehouseDetailDel(params).then(res => {
  462. if (res.status == 200) {
  463. _this.$message.success(res.message)
  464. _this.$refs.table.refresh()
  465. _this.$refs.chooseTable.refresh()
  466. _this.spinning = false
  467. } else {
  468. _this.spinning = false
  469. }
  470. })
  471. }
  472. })
  473. },
  474. // 提交
  475. handleSubmit () {
  476. const _this = this
  477. _this.spinning = true
  478. allocWarehouseSubmit({ id: this.$route.params.id }).then(res => {
  479. if (res.status == 200) {
  480. this.$message.success(res.message)
  481. setTimeout(() => {
  482. _this.handleBack()
  483. _this.spinning = false
  484. }, 1000)
  485. } else {
  486. _this.spinning = false
  487. }
  488. })
  489. },
  490. // 确认导入产品
  491. hanldeImprotOk (obj) {
  492. this.spinning = true
  493. importProductInsertBatch(obj).then(res => {
  494. if (res.status == 200) {
  495. this.resetSearchForm()
  496. }
  497. this.spinning = false
  498. })
  499. },
  500. // 合计
  501. getDetailCount (params) {
  502. allocWarehouseDetailCount(params).then(res => {
  503. if (res.status == 200) {
  504. this.productTotal = res.data
  505. } else {
  506. this.productTotal = null
  507. }
  508. })
  509. },
  510. // 返回列表
  511. handleBack () {
  512. this.$router.push({ path: '/allocationManagement/warehouseAllocation/list' })
  513. },
  514. // 已选产品 调出数量 blur
  515. outQtyBlur (val, record) {
  516. // 光标移出,值发生改变再调用编辑接口
  517. if (val != record.outQtyBackups) {
  518. this.handleAdd(record, 'edit')
  519. }
  520. },
  521. // 已选产品 仓位 change
  522. chooseWarehouseLocChange (row) {
  523. const params = {
  524. allocationWarehouseSn: this.$route.params.sn,
  525. productSn: row.productSn,
  526. outWarehouseLocationSn: row.outWarehouseLocationSn,
  527. putWarehouseLocationSn: row.putWarehouseLocationSn
  528. }
  529. this.spinning = true
  530. updatePutWhLocation(params).then(res => {
  531. if (res.status == 200) {
  532. this.$message.success(res.message)
  533. this.$refs.table.refresh()
  534. this.$refs.chooseTable.refresh()
  535. this.spinning = false
  536. } else {
  537. this.spinning = false
  538. }
  539. })
  540. },
  541. // 产品分类 change
  542. changeProductType (val, opt) {
  543. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  544. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  545. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  546. },
  547. // 获取仓库仓位
  548. getWarehouseLoc (sn, type) {
  549. warehouseLocAllList({ warehouseSn: sn }).then(res => {
  550. if (type == 'put') {
  551. this.warehousePutLocData = res.data || []
  552. } else if (type == 'out') {
  553. this.warehouseOutLocData = res.data || []
  554. }
  555. })
  556. },
  557. pageInit () {
  558. this.chooseResetSearchForm()
  559. this.getDetail()
  560. }
  561. },
  562. mounted () {
  563. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  564. this.pageInit()
  565. }
  566. },
  567. activated () {
  568. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  569. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  570. this.pageInit()
  571. }
  572. },
  573. beforeRouteEnter (to, from, next) {
  574. next(vm => {})
  575. }
  576. }
  577. </script>
  578. <style lang="less">
  579. .warehouseAllocationEdit-wrap{
  580. position: relative;
  581. height: 100%;
  582. padding-bottom: 51px;
  583. box-sizing: border-box;
  584. .warehouseAllocationEdit-back, .warehouseAllocationEdit-cont{
  585. margin-bottom: 10px;
  586. }
  587. >.ant-spin-nested-loading{
  588. overflow-y: auto;
  589. height: 100%;
  590. }
  591. }
  592. </style>