edit.vue 27 KB

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