edit.vue 31 KB

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