edit.vue 29 KB

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