edit.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. <template>
  2. <div class="bulkWarehousingOrderEdit-wrap">
  3. <!-- 内容 -->
  4. <a-page-header :ghost="false" :backIcon="false" class="bulkWarehousingOrderEdit-cont" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="bulkWarehousingOrderEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <p style=" display: inline-block;margin: 0 0 0 60px;color: #000;font-size: 16px;font-weight: 600;">单号:{{ (basicInfoData&&basicInfoData.sparePartsPurchaseNo) || '' }}</p>
  9. </template>
  10. <!-- 操作区,位于 title 行的行尾 -->
  11. <template slot="extra">
  12. <a-button key="2" id="bulkWarehousingOrderEdit-preview-btn">打印预览</a-button>
  13. <a-button key="1" type="primary" id="bulkWarehousingOrderEdit-print-btn">快速打印</a-button>
  14. </template>
  15. </a-page-header>
  16. <!-- 基础信息 -->
  17. <a-card size="small" :bordered="false" class="bulkWarehousingOrderEdit-cont">
  18. <a-collapse :activeKey="['1']">
  19. <a-collapse-panel key="1">
  20. <template slot="header">
  21. 基础信息
  22. <!-- <a-button type="primary" shape="circle" size="small" icon="edit" class="edit-circle-btn" id="bulkWarehousingOrderEdit-edit-circle-btn" @click.stop="handleEditInfo" /> -->
  23. </template>
  24. <a-descriptions :column="3">
  25. <a-descriptions-item label="供应商">{{ (basicInfoData&&basicInfoData.supplierName) || '--' }}</a-descriptions-item>
  26. <a-descriptions-item label="散件入库类型">{{ (basicInfoData&&basicInfoData.sparePartsTypeName) || '--' }}</a-descriptions-item>
  27. <a-descriptions-item label="备注">{{ (basicInfoData&&basicInfoData.remarks) || '--' }}</a-descriptions-item>
  28. </a-descriptions>
  29. </a-collapse-panel>
  30. </a-collapse>
  31. </a-card>
  32. <!-- 选择产品 -->
  33. <a-card size="small" :bordered="false" class="bulkWarehousingOrderEdit-cont">
  34. <a-collapse :activeKey="['1']">
  35. <a-collapse-panel key="1">
  36. <template slot="header">
  37. 选择产品<span class="sub-title">①输入查询条件--->②查找到需要入库的配件--->③录入成本价、数量、仓库、仓位--->④点击“添加”</span>
  38. </template>
  39. <!-- 选择产品 -->
  40. <div>
  41. <!-- 搜索条件 -->
  42. <div class="table-page-search-wrapper">
  43. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  44. <a-row :gutter="15">
  45. <a-col :md="6" :sm="24">
  46. <a-form-item label="关键词">
  47. <a-input id="bulkWarehousingOrderEdit-queryWord" v-model.trim="queryParam.queryWord" allowClear placeholder="产品名称/产品编码/原厂编码"/>
  48. </a-form-item>
  49. </a-col>
  50. <a-col :md="6" :sm="24">
  51. <a-form-item label="产品品牌">
  52. <a-select
  53. placeholder="请选择产品品牌"
  54. id="bulkWarehousingOrderEdit-productBrandSn"
  55. allowClear
  56. v-model="queryParam.productBrandSn"
  57. :showSearch="true"
  58. option-filter-prop="children"
  59. :filter-option="filterOption">
  60. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  61. </a-select>
  62. </a-form-item>
  63. </a-col>
  64. <a-col :md="6" :sm="24">
  65. <a-form-item label="产品分类">
  66. <a-cascader
  67. @change="changeProductType"
  68. change-on-select
  69. v-model="productType"
  70. expand-trigger="hover"
  71. :options="productTypeList"
  72. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  73. id="productInfoList-productType"
  74. placeholder="请选择产品分类"
  75. allowClear />
  76. </a-form-item>
  77. </a-col>
  78. <a-col :md="6" :sm="24">
  79. <a-button style="margin-bottom: 18px;" type="primary" @click="getDealerProductList(1)" :disabled="disabled" id="bulkWarehousingOrderEdit-refresh">查询</a-button>
  80. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="bulkWarehousingOrderEdit-reset">重置</a-button>
  81. </a-col>
  82. </a-row>
  83. </a-form>
  84. </div>
  85. <!-- 列表 -->
  86. <a-table
  87. class="sTable"
  88. ref="table"
  89. size="small"
  90. :rowKey="(record) => record.id"
  91. :columns="columns"
  92. :customRow="handleClickRow"
  93. :dataSource="loadData"
  94. :scroll="{ x: 1600, y: 300 }"
  95. :pagination="paginationProps"
  96. @change="onTableChange"
  97. bordered>
  98. <!-- 成本价 -->
  99. <template slot="putCost" slot-scope="text, record">
  100. <a-input-number
  101. id="bulkWarehousingOrderEdit-putCost"
  102. v-model="record.putCost"
  103. :precision="2"
  104. :min="1"
  105. :max="999999"
  106. placeholder="请输入"
  107. style="width: 100%;" />
  108. </template>
  109. <!-- 数量 -->
  110. <template slot="putQty" slot-scope="text, record">
  111. <a-input-number
  112. id="bulkWarehousingOrderEdit-putQty"
  113. v-model="record.putQty"
  114. :precision="0"
  115. :min="1"
  116. :max="999999"
  117. placeholder="请输入"
  118. style="width: 100%;" />
  119. </template>
  120. <!-- 仓库仓位 -->
  121. <template slot="warehouse" slot-scope="text, record, index">
  122. <a-cascader
  123. @change="e => changeWarehouseCascade(e, record, index, 'dealerProduct')"
  124. v-model="record.warehouseCascade"
  125. expand-trigger="hover"
  126. :allowClear="false"
  127. :options="warehouseCascadeData"
  128. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  129. id="bulkWarehousingOrderEdit-warehouseCascade"
  130. placeholder="请选择仓库仓位"
  131. style="width: 100%;" />
  132. </template>
  133. <!-- 操作 -->
  134. <template slot="action" slot-scope="text, record">
  135. <a-button size="small" type="primary" class="button-primary" @click="handleAdd(record)" id="bulkWarehousingOrderEdit-add-btn">添加</a-button>
  136. </template>
  137. </a-table>
  138. </div>
  139. </a-collapse-panel>
  140. </a-collapse>
  141. </a-card>
  142. <!-- 已选产品 -->
  143. <a-card size="small" :bordered="false" class="bulkWarehousingOrderEdit-cont">
  144. <a-collapse :activeKey="['1']">
  145. <a-collapse-panel key="1">
  146. <template slot="header">
  147. 已选产品
  148. <a-button size="small" class="import-btn" id="bulkWarehousingOrderEdit-import-btn" @click.stop="handleImport">导入明细</a-button>
  149. </template>
  150. <!-- 已选产品 -->
  151. <div>
  152. <!-- 总计 -->
  153. <a-alert type="info" showIcon style="margin-bottom:15px">
  154. <div slot="message">总款数 <strong>{{ (productTotal&&productTotal.productTotalCategory) || 0 }}</strong> ,总数量 <strong>{{ (productTotal&&productTotal.productTotalQty) || 0 }}</strong> ,总成本¥<strong>{{ (productTotal&&productTotal.productTotalCost) || 0 }}</strong></div>
  155. </a-alert>
  156. <!-- 列表 -->
  157. <a-table
  158. class="sTable"
  159. ref="chooseTable"
  160. size="small"
  161. :rowKey="(record) => record.id"
  162. :columns="chooseColumns"
  163. :dataSource="chooseLoadData"
  164. :scroll="{ x: 1700, y: 300 }"
  165. :pagination="choosePaginationProps"
  166. @change="onChooseTableChange"
  167. bordered>
  168. <!-- 成本价 -->
  169. <template slot="putCost" slot-scope="text, record">
  170. <a-input-number
  171. id="bulkWarehousingOrderEdit-choose-putCost"
  172. v-model="record.putCost"
  173. :precision="2"
  174. :min="1"
  175. :max="999999"
  176. placeholder="请输入"
  177. @blur="e => putCostBlur(e.target.value, record)"
  178. style="width: 100%;" />
  179. </template>
  180. <!-- 数量 -->
  181. <template slot="putQty" slot-scope="text, record">
  182. <a-input-number
  183. id="bulkWarehousingOrderEdit-choose-putQty"
  184. v-model="record.putQty"
  185. :precision="0"
  186. :min="1"
  187. :max="999999"
  188. placeholder="请输入"
  189. @blur="e => putQtyBlur(e.target.value, record)"
  190. style="width: 100%;" />
  191. </template>
  192. <!-- 仓库仓位 -->
  193. <template slot="warehouse" slot-scope="text, record, index">
  194. <a-cascader
  195. @change="e => changeWarehouseCascade(e, record, index, 'sparePartsPurDetail')"
  196. v-model="record.warehouseCascade"
  197. expand-trigger="hover"
  198. :allowClear="false"
  199. :options="warehouseCascadeData"
  200. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  201. id="bulkWarehousingOrderEdit-choose-warehouseCascade"
  202. placeholder="请选择仓库仓位"
  203. style="width: 100%;" />
  204. </template>
  205. <!-- 操作 -->
  206. <template slot="action" slot-scope="text, record">
  207. <a-button size="small" type="primary" class="button-error" @click="handleDel(record)" id="bulkWarehousingOrderEdit-del-btn">删除</a-button>
  208. </template>
  209. </a-table>
  210. </div>
  211. </a-collapse-panel>
  212. </a-collapse>
  213. </a-card>
  214. <a-affix :offset-bottom="0">
  215. <div style="text-align: center;width: 100%;background-color: #fff;padding: 12px 0;box-shadow: 0 0 20px #dcdee2;">
  216. <a-button
  217. type="primary"
  218. id="bulkWarehousingOrderEdit-submit"
  219. size="large"
  220. class="button-primary"
  221. @click="handleSubmit"
  222. style="padding: 0 60px;">提交</a-button>
  223. </div>
  224. </a-affix>
  225. <!-- 选择基本信息弹框 -->
  226. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  227. </div>
  228. </template>
  229. <script>
  230. import { STable, VSelect } from '@/components'
  231. import basicInfoModal from './basicInfoModal.vue'
  232. import { getOperationalPrecision } from '@/libs/tools.js'
  233. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  234. import { dealerProductTypeList } from '@/api/dealerProductType'
  235. import { sparePartsPurDetail, sparePartsPurDetailList, sparePartsPurDetailCount, sparePartsPurDetailSave, sparePartsPurDetailDel, sparePartsPurSubmit } from '@/api/sparePartsPur'
  236. import { dealerProductList } from '@/api/dealerProduct'
  237. import { warehouseCascadeList } from '@/api/warehouse'
  238. export default {
  239. components: { STable, VSelect, basicInfoModal },
  240. data () {
  241. return {
  242. queryParam: {
  243. queryWord: '',
  244. productBrandSn: undefined,
  245. productTypeSn1: undefined,
  246. productTypeSn2: undefined,
  247. productTypeSn3: undefined
  248. },
  249. productBrandList: [], // 产品品牌 下拉数据
  250. productTypeList: [], // 产品分类 下拉数据
  251. productType: [],
  252. warehouseCascadeData: [], // 仓库仓位
  253. disabled: false, // 查询、重置按钮是否可操作
  254. // 表头
  255. columns: [
  256. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  257. { title: '产品编码', dataIndex: 'code', width: 220, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  258. { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  259. { title: '原厂编码', dataIndex: 'origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  260. { title: '产品品牌', dataIndex: 'productBrandName', width: 200, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  261. { title: '单位', dataIndex: 'unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  262. { title: '成本价', scopedSlots: { customRender: 'putCost' }, width: 140, align: 'center' },
  263. { title: '数量', scopedSlots: { customRender: 'putQty' }, width: 140, align: 'center' },
  264. { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: 200, align: 'center' },
  265. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  266. ],
  267. loadData: [],
  268. pageNo: 1, // 分页页码
  269. pageSize: 10, // 分页 每页多少条
  270. paginationProps: {
  271. showSizeChanger: true, // 是否可以改变 pageSize
  272. total: 0, // 分页总条数
  273. current: 1,
  274. onShowSizeChange: (current, pageSize) => this.changePageSize(current, pageSize),
  275. onChange: (current) => this.changePage(current)
  276. },
  277. // 表头
  278. chooseColumns: [
  279. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  280. { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', sorter: true },
  281. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  282. { title: '原厂编码', dataIndex: 'productOrigCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  283. { title: '产品品牌', dataIndex: 'brandName', width: 200, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  284. { title: '单位', dataIndex: 'productUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  285. { title: '成本价', scopedSlots: { customRender: 'putCost' }, width: 140, align: 'center' },
  286. { title: '数量', scopedSlots: { customRender: 'putQty' }, width: 140, align: 'center' },
  287. { title: '成本小计', dataIndex: 'costSubtotal', width: 100, align: 'center' },
  288. { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: 200, align: 'center' },
  289. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  290. ],
  291. chooseLoadData: [],
  292. choosePageNo: 1, // 分页页码
  293. choosePageSize: 10, // 分页 每页多少条
  294. choosePaginationProps: {
  295. showSizeChanger: true, // 是否可以改变 pageSize
  296. total: 0, // 分页总条数
  297. current: 1,
  298. onShowSizeChange: (current, pageSize) => this.changeChoosePageSize(current, pageSize),
  299. onChange: (current) => this.changeChoosePage(current)
  300. },
  301. openModal: false, // 选择基本信息弹框是否显示
  302. warehouseList: [], // 仓库 下拉数据
  303. warehouseLocList: {}, // 仓位 下拉数据
  304. defaultWarehouseCascade: [], // 默认仓库仓位
  305. chooseWarehouseList: [], // 已选产品 仓库 下拉数据
  306. chooseWarehouseLocList: {}, // 已选产品 仓位 下拉数据
  307. basicInfoData: null, // 基本信息
  308. productTotal: null // 合计
  309. }
  310. },
  311. methods: {
  312. // 重置
  313. resetSearchForm () {
  314. this.queryParam.queryWord = ''
  315. this.queryParam.productBrandSn = undefined
  316. this.queryParam.productTypeSn1 = ''
  317. this.queryParam.productTypeSn2 = ''
  318. this.queryParam.productTypeSn3 = ''
  319. this.productType = []
  320. this.pageNo = 1
  321. this.pageSize = 10
  322. this.paginationProps.total = 0
  323. this.paginationProps.current = 1
  324. this.getDealerProductList(1)
  325. },
  326. // 双击快速添加
  327. handleClickRow (record) {
  328. return {
  329. on: {
  330. dblclick: (event) => {
  331. this.handleAdd(record)
  332. }
  333. }
  334. }
  335. },
  336. // 分页 一页多少条change
  337. changePageSize (current, pageSize) {
  338. this.pageNo = current
  339. this.pageSize = pageSize
  340. this.getDealerProductList()
  341. },
  342. // 分页 页码change
  343. changePage (current) {
  344. this.pageNo = current
  345. this.getDealerProductList()
  346. },
  347. // 已选产品 分页 一页多少条change
  348. changeChoosePageSize (current, pageSize) {
  349. this.choosePageNo = current
  350. this.choosePageSize = pageSize
  351. this.getChooseDealerProductList()
  352. },
  353. // 已选产品 分页 页码change
  354. changeChoosePage (current) {
  355. this.choosePageNo = current
  356. this.getChooseDealerProductList()
  357. },
  358. // 基本信息
  359. getDetail () {
  360. sparePartsPurDetail({ id: this.$route.params.id }).then(res => {
  361. if (res.status == 200) {
  362. this.basicInfoData = res.data
  363. } else {
  364. this.basicInfoData = null
  365. }
  366. })
  367. },
  368. // 添加/编辑
  369. handleAdd (row, isEdit) {
  370. if (!isEdit && !row.putCost) {
  371. this.$message.warning('请输入成本价后再添加!')
  372. return
  373. }
  374. if (!isEdit && !row.putQty) {
  375. this.$message.warning('请输入数量后再添加!')
  376. return
  377. }
  378. if (!isEdit && !row.warehouseSn) {
  379. this.$message.warning('请选择仓库后再添加!')
  380. return
  381. }
  382. if (!isEdit && !row.warehouseLocationSn) {
  383. this.$message.warning('请选择仓位后再添加!')
  384. return
  385. }
  386. const params = {
  387. id: isEdit ? row.id : undefined,
  388. sparePartsPurchaseSn: this.$route.params.sn,
  389. putCost: row.putCost,
  390. putQty: row.putQty,
  391. productCode: isEdit ? row.productCode : row.code,
  392. productOrigCode: (isEdit ? row.productOrigCode : row.origCode) || undefined,
  393. productSn: row.productSn,
  394. productTypeSn1: row.productTypeSn1,
  395. productTypeSn2: row.productTypeSn2,
  396. productTypeSn3: row.productTypeSn3,
  397. brandSn: isEdit ? row.brandSn : row.productBrandSn,
  398. warehouseLocationSn: row.warehouseLocationSn,
  399. warehouseSn: row.warehouseSn
  400. }
  401. if (isEdit) { // 编辑
  402. // 清空成本价或数量时,值应保持未清空前的值,因成本价和数量都不可为空
  403. if (!row.putCost) {
  404. row.putCost = row.putCostBackups
  405. return
  406. }
  407. if (!row.putQty) {
  408. row.putQty = row.putQtyBackups
  409. return
  410. }
  411. }
  412. sparePartsPurDetailSave(params).then(res => {
  413. if (res.status == 200) {
  414. this.$message.success(res.message)
  415. this.getChooseDealerProductList()
  416. }
  417. })
  418. },
  419. // 提交
  420. handleSubmit () {
  421. const _this = this
  422. sparePartsPurSubmit({ id: this.$route.params.id }).then(res => {
  423. if (res.status == 200) {
  424. this.$message.success(res.message)
  425. setTimeout(() => {
  426. _this.handleBack()
  427. }, 1000)
  428. }
  429. })
  430. },
  431. // 删除
  432. handleDel (row) {
  433. const _this = this
  434. this.$confirm({
  435. title: '提示',
  436. content: '删除后不可恢复,确定要进行删除吗?',
  437. centered: true,
  438. onOk () {
  439. sparePartsPurDetailDel({ id: row.id }).then(res => {
  440. if (res.status == 200) {
  441. _this.$message.success(res.message)
  442. _this.getChooseDealerProductList()
  443. }
  444. })
  445. }
  446. })
  447. },
  448. // 编辑基本信息
  449. handleEditInfo () {
  450. this.openModal = true
  451. },
  452. // 基本信息 保存
  453. handleOk () {},
  454. // 导入明细
  455. handleImport () {
  456. console.log(333)
  457. },
  458. // 返回列表
  459. handleBack () {
  460. this.$router.push({ path: '/bulkManagement/bulkWarehousingOrder/list' })
  461. },
  462. // 合计
  463. getDetailCount (params) {
  464. sparePartsPurDetailCount(params).then(res => {
  465. if (res.status == 200) {
  466. this.productTotal = res.data
  467. } else {
  468. this.productTotal = null
  469. }
  470. })
  471. },
  472. changeWarehouseCascade (val, opt, ind, type) {
  473. let loadData
  474. if (type == 'dealerProduct') { // 全部产品
  475. loadData = this.loadData[ind]
  476. } else if (type == 'sparePartsPurDetail') { // 已选产品
  477. loadData = this.chooseLoadData[ind]
  478. }
  479. if (val.length < 2) {
  480. this.$message.warning('当前仓库无仓位,请选择其他仓库')
  481. const warehouseSnBackups = loadData.warehouseSnBackups || undefined
  482. const warehouseLocationSnBackups = loadData.warehouseLocationSnBackups || undefined
  483. loadData.warehouseSn = warehouseSnBackups
  484. loadData.warehouseLocationSn = warehouseLocationSnBackups
  485. if (warehouseSnBackups || warehouseLocationSnBackups) {
  486. loadData.warehouseCascade = [warehouseSnBackups, warehouseLocationSnBackups]
  487. } else {
  488. loadData.warehouseCascade = undefined
  489. }
  490. } else {
  491. loadData.warehouseSn = val[0] ? val[0] : ''
  492. loadData.warehouseLocationSn = val[1] ? val[1] : ''
  493. if (type == 'sparePartsPurDetail') { // 已选产品
  494. loadData = this.chooseLoadData[ind]
  495. this.handleAdd(loadData, 'edit')
  496. }
  497. }
  498. },
  499. // 已选产品 成本价 blur
  500. putCostBlur (val, record) {
  501. // 光标移出,值发生改变再调用编辑接口
  502. if (val != record.putCostBackups) {
  503. this.handleAdd(record, 'edit')
  504. }
  505. },
  506. // 已选产品 数量 blur
  507. putQtyBlur (val, record) {
  508. if (val != record.putQtyBackups) {
  509. this.handleAdd(record, 'edit')
  510. }
  511. },
  512. // 产品分类 change
  513. changeProductType (val, opt) {
  514. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  515. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  516. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  517. },
  518. // 产品列表数据
  519. getDealerProductList (pageNo, sorter) {
  520. this.disabled = true
  521. this.pageNo = pageNo || this.pageNo
  522. const params = Object.assign({ pageNo: this.pageNo, pageSize: this.pageSize }, this.queryParam)
  523. params.enabledFlag = 1
  524. params.sysFlag = 0
  525. if (sorter) {
  526. params.sortField = sorter.field
  527. params.sortOrder = sorter.order
  528. params.sortAlias = 'dp'
  529. }
  530. dealerProductList(params).then(res => {
  531. if (res.status == 200) {
  532. const data = res.data
  533. this.paginationProps.total = Number(res.data.count) || 0
  534. this.paginationProps.current = this.pageNo
  535. const no = (data.pageNo - 1) * data.pageSize
  536. for (var i = 0; i < data.list.length; i++) {
  537. data.list[i].no = no + i + 1
  538. if (this.defaultWarehouseCascade.length > 0) {
  539. data.list[i].warehouseCascade = this.defaultWarehouseCascade
  540. data.list[i].warehouseSn = this.defaultWarehouseCascade[0]
  541. data.list[i].warehouseLocationSn = this.defaultWarehouseCascade[1]
  542. } else {
  543. data.list[i].warehouseCascade = undefined
  544. }
  545. }
  546. this.loadData = data.list
  547. this.disabled = false
  548. } else {
  549. this.paginationProps.total = 0
  550. this.paginationProps.current = 1
  551. this.loadData = []
  552. }
  553. })
  554. },
  555. // 已选产品列表数据
  556. getChooseDealerProductList (pageNo, sorter) {
  557. this.choosePageNo = pageNo || this.choosePageNo
  558. const params = {
  559. pageNo: this.choosePageNo,
  560. pageSize: this.choosePageSize,
  561. sparePartsPurchaseSn: this.$route.params.sn
  562. }
  563. if (sorter) {
  564. params.sortField = sorter.field == 'brandName' ? 'productBrandName' : 'productCode'
  565. params.sortOrder = sorter.order
  566. params.sortAlias = sorter.field == 'brandName' ? 'dp' : 'sppd'
  567. }
  568. sparePartsPurDetailList(params).then(res => {
  569. if (res.status == 200) {
  570. this.getDetailCount(params)
  571. const data = res.data
  572. this.choosePaginationProps.total = Number(res.data.count) || 0
  573. this.choosePaginationProps.current = data.pageNo
  574. const no = (data.pageNo - 1) * data.pageSize
  575. for (var i = 0; i < data.list.length; i++) {
  576. data.list[i].no = no + i + 1
  577. data.list[i].putCostBackups = data.list[i].putCost
  578. data.list[i].putQtyBackups = data.list[i].putQty
  579. const warehouseSn = data.list[i].warehouseSn || undefined
  580. const warehouseLocationSn = data.list[i].warehouseLocationSn || undefined
  581. if (warehouseSn || warehouseLocationSn) {
  582. data.list[i].warehouseSnBackups = warehouseSn
  583. data.list[i].warehouseLocationSnBackups = warehouseLocationSn
  584. data.list[i].warehouseCascade = [warehouseSn, warehouseLocationSn]
  585. } else {
  586. data.list[i].warehouseCascade = undefined
  587. }
  588. // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  589. data.list[i].costSubtotal = getOperationalPrecision(data.list[i].putCost, data.list[i].putQty)
  590. }
  591. this.chooseLoadData = data.list
  592. } else {
  593. this.choosePaginationProps.total = 0
  594. this.choosePaginationProps.current = 1
  595. this.chooseLoadData = []
  596. }
  597. })
  598. },
  599. // 仓库仓位 级联 列表
  600. getWarehouseCascade () {
  601. const _this = this
  602. warehouseCascadeList({}).then(res => {
  603. if (res.status == 200) {
  604. res.data.filter(item => {
  605. // 过滤默认仓库
  606. if (item.defaultFlag == 1 && item.wasteFlag == 0) { // defaultFlag为1,且不是废品仓
  607. _this.defaultWarehouseCascade[0] = item.warehouseSn
  608. // 过滤默认仓位
  609. item.warehouseLocationList.filter(subItem => {
  610. if (subItem.defaultFlag == 1 && subItem.wasteFlag == 0) {
  611. _this.defaultWarehouseCascade[1] = subItem.warehouseLocationSn
  612. _this.getDealerProductList(1)
  613. _this.getChooseDealerProductList(1)
  614. }
  615. })
  616. }
  617. })
  618. res.data.map(item => {
  619. item.sn = item.warehouseSn
  620. if (item.warehouseLocationList) {
  621. item.warehouseLocationList.map(subItem => {
  622. subItem.sn = subItem.warehouseLocationSn
  623. })
  624. }
  625. })
  626. this.warehouseCascadeData = res.data
  627. } else {
  628. this.warehouseCascadeData = []
  629. }
  630. })
  631. },
  632. // 产品品牌 列表
  633. getProductBrand () {
  634. // sysFlag传0,表示只查自建产品
  635. dealerProductBrandQuery({ 'sysFlag': '0' }).then(res => {
  636. if (res.status == 200) {
  637. this.productBrandList = res.data
  638. } else {
  639. this.productBrandList = []
  640. }
  641. })
  642. },
  643. // 产品分类 列表
  644. getProductType () {
  645. dealerProductTypeList({ 'sysFlag': '0' }).then(res => {
  646. if (res.status == 200) {
  647. this.productTypeList = res.data
  648. } else {
  649. this.productTypeList = []
  650. }
  651. })
  652. },
  653. filterOption (input, option) {
  654. return (
  655. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  656. )
  657. },
  658. // 选择产品 表格 change
  659. onTableChange (pagination, filters, sorter) {
  660. console.log('-------------------------------')
  661. console.log('params', pagination, filters, sorter)
  662. this.getDealerProductList(this.pageNo, sorter)
  663. },
  664. // 已选产品 表格 change
  665. onChooseTableChange (pagination, filters, sorter) {
  666. console.log('++++++++++++++++++++++++++++++++++')
  667. this.getChooseDealerProductList(this.choosePageNo, sorter)
  668. }
  669. },
  670. beforeRouteEnter (to, from, next) {
  671. next(vm => {
  672. vm.openModal = false
  673. vm.getChooseDealerProductList(1)
  674. vm.getWarehouseCascade()
  675. vm.getDetail()
  676. vm.getProductBrand()
  677. vm.getProductType()
  678. })
  679. }
  680. }
  681. </script>
  682. <style lang="less">
  683. .bulkWarehousingOrderEdit-wrap{
  684. .bulkWarehousingOrderEdit-cont{
  685. margin-bottom: 15px;
  686. .sub-title{
  687. font-size: 12px;
  688. color: #808695;
  689. margin-left: 10px;
  690. }
  691. .tag-txt{
  692. font-size: 12px;
  693. color: #ed1c24;
  694. }
  695. .edit-circle-btn{
  696. margin-left: 15px;
  697. i{
  698. vertical-align: text-bottom;
  699. }
  700. }
  701. .import-btn{
  702. margin-left: 15px;
  703. }
  704. }
  705. }
  706. </style>