edit.vue 32 KB

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