edit.vue 27 KB

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