edit.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  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 30px 0 60px;color: #000;font-size: 16px;font-weight: 600;">单号:{{ (basicInfoData&&basicInfoData.sparePartsPurchaseNo) || '' }}</p>
  10. <a-button type="primary" ghost @click="isShowBisiceInfo=!isShowBisiceInfo">
  11. 基础信息
  12. <a-icon :type="isShowBisiceInfo ? 'up' : 'down'"/>
  13. </a-button>
  14. </template>
  15. <!-- 操作区,位于 title 行的行尾 -->
  16. <template slot="extra" v-if="$hasPermissions('B_bulkWarehousingOrder_print')">
  17. <Print :disabled="chooseLoadDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
  18. </template>
  19. </a-page-header>
  20. <!-- 基础信息 -->
  21. <div v-show="isShowBisiceInfo" class="bulkWarehousingOrderEdit-cont">
  22. <a-collapse :activeKey="['1']">
  23. <a-collapse-panel key="1" header="基础信息" :disabled="true">
  24. <a-row :gutter="16">
  25. <a-col class="gutter-row" :span="8">
  26. 供应商:{{ (basicInfoData&&basicInfoData.supplierName) || '--' }}
  27. </a-col>
  28. <a-col class="gutter-row" :span="8">
  29. 散件入库类型:{{ (basicInfoData&&basicInfoData.sparePartsTypeName) || '--' }}
  30. </a-col>
  31. <a-col class="gutter-row" :span="8">
  32. 备注:{{ (basicInfoData&&basicInfoData.remarks) || '--' }}
  33. </a-col>
  34. </a-row>
  35. </a-collapse-panel>
  36. </a-collapse>
  37. </div>
  38. <!-- 选择产品 -->
  39. <div class="bulkWarehousingOrderEdit-cont">
  40. <a-collapse :activeKey="['1']">
  41. <a-collapse-panel key="1">
  42. <template slot="header">
  43. 选择产品<span class="sub-title">①输入查询条件--->②查找到需要入库的配件--->③录入成本价、数量、仓库、仓位--->④点击“添加”</span>
  44. </template>
  45. <!-- 选择产品 -->
  46. <div>
  47. <!-- 搜索条件 -->
  48. <div class="table-page-search-wrapper">
  49. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  50. <a-row type="flex" :gutter="12" justify="start">
  51. <a-col flex="250px">
  52. <a-form-model-item label="产品编码">
  53. <a-input id="bulkWarehousingOrderEdit-code" ref="searchProductCode" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
  54. </a-form-model-item>
  55. </a-col>
  56. <a-col flex="350px">
  57. <a-form-model-item label="产品名称">
  58. <a-input id="bulkWarehousingOrderEdit-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
  59. </a-form-model-item>
  60. </a-col>
  61. <a-col flex="250px">
  62. <a-form-model-item label="原厂编码">
  63. <a-input id="bulkWarehousingOrderEdit-origCode" v-model.trim="queryParam.origCode" allowClear placeholder="请输入原厂编码"/>
  64. </a-form-model-item>
  65. </a-col>
  66. <template v-if="advanced">
  67. <a-col flex="250px">
  68. <a-form-item label="产品分类">
  69. <ProductType id="productInfoList-productType" @change="changeProductType" v-model="productType"></ProductType>
  70. </a-form-item>
  71. </a-col>
  72. <a-col flex="250px">
  73. <a-form-item label="产品品牌">
  74. <ProductBrand id="bulkWarehousingOrderEdit-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  75. </a-form-item>
  76. </a-col>
  77. </template>
  78. <a-col flex="auto" style="margin-bottom: 10px;">
  79. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="bulkWarehousingOrderEdit-refresh">查询</a-button>
  80. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="bulkWarehousingOrderEdit-reset">重置</a-button>
  81. <a @click="advanced=!advanced" style="margin:0 30px 0 10px">
  82. {{ advanced ? '收起' : '展开' }}
  83. <a-icon :type="advanced ? 'up' : 'down'"/>
  84. </a>
  85. </a-col>
  86. </a-row>
  87. </a-form>
  88. </div>
  89. <!-- 列表 -->
  90. <s-table
  91. class="sTable"
  92. ref="table"
  93. size="small"
  94. :rowKey="(record) => record.id"
  95. :columns="columns"
  96. @dblclick="handleClickRow"
  97. :data="loadData"
  98. :defaultLoadData="false"
  99. :scroll="{ y: 150 }"
  100. bordered>
  101. <!-- 成本价 -->
  102. <template slot="putCost" slot-scope="text, record">
  103. <div @dblclick.stop>
  104. <a-input-number
  105. size="small"
  106. id="bulkWarehousingOrderEdit-putCost"
  107. v-model="record.putCost"
  108. :precision="2"
  109. :min="0"
  110. :max="999999"
  111. placeholder="请输入"
  112. class="rightPrice"
  113. style="width: 100%;" />
  114. </div>
  115. </template>
  116. <!-- 数量 -->
  117. <template slot="putQty" slot-scope="text, record">
  118. <div @dblclick.stop>
  119. <a-input-number
  120. size="small"
  121. @dblclick.stop
  122. id="bulkWarehousingOrderEdit-putQty"
  123. v-model="record.putQty"
  124. :precision="0"
  125. :min="1"
  126. :max="999999"
  127. placeholder="请输入"
  128. style="width: 100%;" />
  129. </div>
  130. </template>
  131. <!-- 仓库仓位 -->
  132. <template slot="warehouse" slot-scope="text, record, index">
  133. <div @dblclick.stop>
  134. <a-cascader
  135. size="small"
  136. @change="e => changeWarehouseCascade(e, record, index, 'dealerProduct')"
  137. v-model="record.warehouseCascade"
  138. expand-trigger="hover"
  139. :allowClear="false"
  140. :options="warehouseCascadeData"
  141. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  142. id="bulkWarehousingOrderEdit-warehouseCascade"
  143. placeholder="请选择仓库仓位"
  144. style="width: 100%;" />
  145. </div>
  146. </template>
  147. <!-- 操作 -->
  148. <template slot="action" slot-scope="text, record">
  149. <a-button size="small" type="link" class="button-primary" @click="handleAdd(record)" id="bulkWarehousingOrderEdit-add-btn">添加</a-button>
  150. </template>
  151. </s-table>
  152. </div>
  153. </a-collapse-panel>
  154. </a-collapse>
  155. </div>
  156. <!-- 已选产品 -->
  157. <div class="bulkWarehousingOrderEdit-cont">
  158. <a-collapse :activeKey="['1']">
  159. <a-collapse-panel key="1">
  160. <template slot="header">
  161. 已选产品
  162. </template>
  163. <!-- 已选产品 -->
  164. <div>
  165. <!-- 总计 -->
  166. <a-alert type="info" style="margin-bottom:10px">
  167. <div slot="message">
  168. 总款数 <strong>{{ (productTotal&&(productTotal.productTotalCategory || productTotal.productTotalCategory==0)) ? productTotal.productTotalCategory : '--' }}</strong> ,
  169. 总数量 <strong>{{ (productTotal&&(productTotal.productTotalQty || productTotal.productTotalQty==0)) ? productTotal.productTotalQty : '--' }}</strong> ,
  170. 总成本 <strong>{{ (productTotal&&(productTotal.productTotalCost || productTotal.productTotalCost==0)) ? toThousands(productTotal.productTotalCost,2) : '--' }}</strong>
  171. </div>
  172. </a-alert>
  173. <div class="table-page-search-wrapper">
  174. <a-form layout="inline" @keyup.enter.native="$refs.chooseTable.refresh(true)">
  175. <a-row :gutter="15">
  176. <a-col :md="4" :sm="24">
  177. <a-form-model-item label="产品编码">
  178. <a-input id="bulkWarehousingOrderEdit-code" v-model.trim="queryChooseParam.productCode" allowClear placeholder="请输入产品编码"/>
  179. </a-form-model-item>
  180. </a-col>
  181. <a-col :md="4" :sm="24">
  182. <a-form-model-item label="产品名称">
  183. <a-input id="bulkWarehousingOrderEdit-name" v-model.trim="queryChooseParam.productName" allowClear placeholder="请输入产品名称"/>
  184. </a-form-model-item>
  185. </a-col>
  186. <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
  187. <a-button type="primary" @click="$refs.chooseTable.refresh(true)" :disabled="disabled" id="bulkWarehousingOrderEdit-choose-refresh">查询</a-button>
  188. <a-button style="margin-left: 8px" @click="resetChooseSearchForm" :disabled="disabled" id="bulkWarehousingOrderEdit-choose-reset">重置</a-button>
  189. </a-col>
  190. <a-col :md="4" :sm="24">
  191. </a-col>
  192. <a-col :md="8" :sm="24" style="text-align:right;">
  193. <a-button
  194. type="default"
  195. @click="openGuideModal=true"
  196. :loading="delLoading"
  197. id="bulkWarehousingOrderEdit-del-all">导入产品</a-button>
  198. <a-button
  199. type="link"
  200. @click="delBulkOrder"
  201. :loading="delLoading"
  202. id="bulkWarehousingOrderEdit-del-all">清空列表</a-button>
  203. </a-col>
  204. </a-row>
  205. </a-form>
  206. </div>
  207. <!-- 列表 -->
  208. <s-table
  209. class="sTable"
  210. ref="chooseTable"
  211. size="small"
  212. :rowKey="(record) => record.id"
  213. :columns="chooseColumns"
  214. :data="chooseLoadData"
  215. :defaultLoadData="false"
  216. :scroll="{ y: 200 }"
  217. bordered>
  218. <!-- 成本价 -->
  219. <template slot="putCost" slot-scope="text, record">
  220. <a-input-number
  221. size="small"
  222. id="bulkWarehousingOrderEdit-choose-putCost"
  223. v-model="record.putCost"
  224. :precision="2"
  225. :min="0"
  226. :max="999999"
  227. placeholder="请输入"
  228. class="rightPrice"
  229. @blur="e => putCostBlur(e.target.value, record)"
  230. style="width: 100%;" />
  231. </template>
  232. <!-- 数量 -->
  233. <template slot="putQty" slot-scope="text, record">
  234. <a-input-number
  235. size="small"
  236. id="bulkWarehousingOrderEdit-choose-putQty"
  237. v-model="record.putQty"
  238. :precision="0"
  239. :min="1"
  240. :max="999999"
  241. placeholder="请输入"
  242. @blur="e => putQtyBlur(e.target.value, record)"
  243. style="width: 100%;" />
  244. </template>
  245. <!-- 仓库仓位 -->
  246. <template slot="warehouse" slot-scope="text, record, index">
  247. <a-cascader
  248. size="small"
  249. @change="e => changeWarehouseCascade(e, record, index, 'sparePartsPurDetail')"
  250. v-model="record.warehouseCascade"
  251. expand-trigger="hover"
  252. :allowClear="false"
  253. :options="warehouseCascadeData"
  254. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  255. id="bulkWarehousingOrderEdit-choose-warehouseCascade"
  256. placeholder="请选择仓库仓位"
  257. style="width: 100%;" />
  258. </template>
  259. <!-- 操作 -->
  260. <template slot="action" slot-scope="text, record">
  261. <a-button size="small" type="link" class="button-error" @click="handleDel(record)" id="bulkWarehousingOrderEdit-del-btn">删除</a-button>
  262. </template>
  263. </s-table>
  264. </div>
  265. </a-collapse-panel>
  266. </a-collapse>
  267. </div>
  268. </a-spin>
  269. <div class="affix-cont">
  270. <a-button
  271. type="primary"
  272. id="bulkWarehousingOrderEdit-submit"
  273. size="large"
  274. :disabled="spinning"
  275. class="button-primary"
  276. @click="handleSubmit"
  277. style="padding: 0 60px;">提交</a-button>
  278. </div>
  279. <!-- 导入费用明细 -->
  280. <importGuideModal
  281. :openModal="openGuideModal"
  282. :params="{sparePartsPurchaseSn: $route.params.sn}"
  283. @close="openGuideModal=false"
  284. @ok="hanldeImprotOk" />
  285. <!-- 新增产品 -->
  286. <a-modal
  287. centered
  288. class="newProduct-modal"
  289. :footer="null"
  290. :maskClosable="false"
  291. title="新增产品"
  292. v-model="showNewProduct"
  293. @cancel="showNewProduct=false"
  294. :width="800">
  295. <newProduct
  296. ref="newProduct"
  297. :saveing="spinning"
  298. :paramsData="paramsData"
  299. pageType="modal"
  300. @cansel="showNewProduct=false"
  301. @saveOk="saveProductOk"></newProduct>
  302. </a-modal>
  303. </div>
  304. </template>
  305. <script>
  306. import { commonMixin } from '@/utils/mixin'
  307. import { STable, VSelect } from '@/components'
  308. import { getOperationalPrecision } from '@/libs/tools.js'
  309. import {
  310. sparePartsPurDetail,
  311. sparePartsPurDetailList,
  312. sparePartsPurDetailCount,
  313. sparePartsPurDetailSave,
  314. sparePartsPurDetailDel,
  315. sparePartsPurSubmit,
  316. sparePartsPurDetailPrint,
  317. sparePartsPurDeleteAll,
  318. sparePartsPurDetailInsertBatch } from '@/api/sparePartsPur'
  319. import { bulkProductList } from '@/api/dealerProduct'
  320. import { warehouseCascadeList } from '@/api/warehouse'
  321. import ProductType from '../../common/productType.js'
  322. import ProductBrand from '../../common/productBrand.js'
  323. import Print from '@/views/common/print.vue'
  324. import importGuideModal from './importGuideModal.vue'
  325. import { toThousands } from '@/libs/tools'
  326. import newProduct from '@/views/productManagement/productInfo/edit.vue'
  327. import { hdPrint } from '@/libs/JGPrint'
  328. export default {
  329. name: 'BulkWarehousingEdit',
  330. components: { STable, VSelect, Print, ProductType, ProductBrand, newProduct, importGuideModal },
  331. mixins: [commonMixin],
  332. data () {
  333. return {
  334. isShowBisiceInfo: false,
  335. advanced: false,
  336. spinning: false,
  337. loading: false,
  338. delLoading: false,
  339. chooseLoading: false,
  340. showNewProduct: false,
  341. openGuideModal: false,
  342. queryParam: {
  343. code: '', // 产品编码
  344. name: '', // 产品名称
  345. origCode: '', // 原厂编码
  346. productBrandSn: undefined,
  347. productTypeSn1: undefined,
  348. productTypeSn2: undefined,
  349. productTypeSn3: undefined
  350. },
  351. queryChooseParam: {
  352. productCode: '', // 产品编码
  353. productName: '' // 产品名称
  354. },
  355. productType: [],
  356. warehouseCascadeData: [], // 仓库仓位
  357. disabled: false, // 查询、重置按钮是否可操作
  358. paramsData: null, // 新增产品临时参数
  359. // 表头
  360. columns: [
  361. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  362. { title: '产品编码', dataIndex: 'code', width: '16%', align: 'left', sorter: true, customRender: function (text) { return text || '--' } },
  363. { title: '产品名称', dataIndex: 'name', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  364. { title: '原厂编码', dataIndex: 'origCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  365. { title: '产品品牌', dataIndex: 'productBrandName', width: '10%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  366. { title: '单位', dataIndex: 'unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  367. { title: '成本价', scopedSlots: { customRender: 'putCost' }, width: '7%', align: 'center' },
  368. { title: '数量', scopedSlots: { customRender: 'putQty' }, width: '7%', align: 'center' },
  369. { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: '13%', align: 'center' },
  370. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  371. ],
  372. // 加载数据方法 必须为 Promise 对象
  373. loadData: parameter => {
  374. this.disabled = true
  375. parameter.sortAlias = 'dp'
  376. const params = Object.assign(parameter, this.queryParam, { supplierSn: this.$route.params.supplierSn })
  377. return bulkProductList(params).then(res => {
  378. const data = res.data
  379. const no = (data.pageNo - 1) * data.pageSize
  380. for (var i = 0; i < data.list.length; i++) {
  381. data.list[i].no = no + i + 1
  382. data.list[i].putCost = data.list[i].purchasePrice
  383. data.list[i].putQty = data.list[i].putQty || 1
  384. if (this.defaultWarehouseCascade.length > 0) {
  385. data.list[i].warehouseCascade = this.defaultWarehouseCascade
  386. data.list[i].warehouseSn = this.defaultWarehouseCascade[0]
  387. data.list[i].warehouseLocationSn = this.defaultWarehouseCascade[1]
  388. } else {
  389. data.list[i].warehouseCascade = undefined
  390. }
  391. }
  392. this.loadDataSource = data.list
  393. this.disabled = false
  394. // 如果没有搜索到产品,直接添加产品
  395. this.isAddNewProduct(data.list)
  396. return data
  397. })
  398. },
  399. // 表头
  400. chooseColumns: [
  401. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  402. { title: '产品编码', dataIndex: 'productCode', width: '14%', align: 'left', customRender: function (text) { return text || '--' }, sorter: true },
  403. { title: '产品名称', dataIndex: 'productName', width: '14%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  404. { title: '原厂编码', dataIndex: 'productOrigCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  405. { title: '产品品牌', dataIndex: 'brandName', width: '10%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
  406. { title: '单位', dataIndex: 'productUnit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  407. { title: '成本价', scopedSlots: { customRender: 'putCost' }, width: '7%', align: 'center' },
  408. { title: '数量', scopedSlots: { customRender: 'putQty' }, width: '7%', align: 'center' },
  409. { title: '成本小计', dataIndex: 'costSubtotal', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? toThousands(text, 2) : '--') } },
  410. { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: '13%', align: 'center' },
  411. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  412. ],
  413. // 加载数据方法 必须为 Promise 对象
  414. chooseLoadData: parameter => {
  415. // 排序
  416. if (parameter.sortField == 'brandName') {
  417. parameter.sortField = 'productBrandName'
  418. parameter.sortAlias = 'dp'
  419. }
  420. if (parameter.sortField == 'productName') {
  421. parameter.sortField = 'productCode'
  422. parameter.sortAlias = 'sppd'
  423. }
  424. const params = Object.assign(parameter, this.queryChooseParam, { sparePartsPurchaseSn: this.$route.params.sn })
  425. return sparePartsPurDetailList(params).then(res => {
  426. this.getDetailCount(params)
  427. const data = res.data
  428. const no = (data.pageNo - 1) * data.pageSize
  429. for (var i = 0; i < data.list.length; i++) {
  430. data.list[i].no = no + i + 1
  431. data.list[i].putCostBackups = data.list[i].putCost
  432. data.list[i].putQtyBackups = data.list[i].putQty
  433. const warehouseSn = data.list[i].warehouseSn || undefined
  434. const warehouseLocationSn = data.list[i].warehouseLocationSn || undefined
  435. if (warehouseSn || warehouseLocationSn) {
  436. data.list[i].warehouseSnBackups = warehouseSn
  437. data.list[i].warehouseLocationSnBackups = warehouseLocationSn
  438. data.list[i].warehouseCascade = [warehouseSn, warehouseLocationSn]
  439. } else {
  440. data.list[i].warehouseCascade = undefined
  441. }
  442. // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  443. data.list[i].costSubtotal = getOperationalPrecision(data.list[i].putCost, data.list[i].putQty)
  444. }
  445. this.chooseLoadDataSource = data.list
  446. return data
  447. })
  448. },
  449. loadDataSource: [],
  450. chooseLoadDataSource: [],
  451. warehouseList: [], // 仓库 下拉数据
  452. warehouseLocList: {}, // 仓位 下拉数据
  453. defaultWarehouseCascade: [], // 默认仓库仓位
  454. chooseWarehouseList: [], // 已选产品 仓库 下拉数据
  455. chooseWarehouseLocList: {}, // 已选产品 仓位 下拉数据
  456. basicInfoData: null, // 基本信息
  457. productTotal: null // 合计
  458. }
  459. },
  460. methods: {
  461. // 是否新增产品
  462. isAddNewProduct (data) {
  463. const _this = this
  464. if (data.length == 0) {
  465. _this.$confirm({
  466. title: '提示',
  467. content: '该产品信息不存在,是否马上新增?',
  468. centered: true,
  469. onOk () {
  470. _this.paramsData = {
  471. supplierName: _this.basicInfoData.supplierName,
  472. code: _this.queryParam.code,
  473. name: _this.queryParam.name,
  474. origCode: _this.queryParam.origCode,
  475. putCost: 0,
  476. putQty: 1,
  477. warehouse: []
  478. }
  479. _this.showNewProduct = true
  480. _this.$nextTick(() => {
  481. _this.$refs.newProduct.pageInit()
  482. })
  483. }
  484. })
  485. } else {
  486. // 新添加的产品自动添加到已选产品中
  487. if (data.length == 1 && this.showNewProduct) {
  488. data[0].putCost = this.paramsData.putCost
  489. data[0].putQty = this.paramsData.putQty
  490. data[0].warehouseSn = this.paramsData.warehouse[0] || ''
  491. data[0].warehouseLocationSn = this.paramsData.warehouse[1] || ''
  492. this.handleAdd(data[0])
  493. }
  494. }
  495. },
  496. // 添加产品成功
  497. saveProductOk (data) {
  498. this.paramsData = data
  499. this.queryParam.code = data.code
  500. this.$refs.table.refresh(true)
  501. this.spinning = false
  502. },
  503. // 重置产品列表
  504. resetSearchForm () {
  505. this.queryParam.name = ''
  506. this.queryParam.code = ''
  507. this.queryParam.origCode = ''
  508. this.queryParam.productBrandSn = undefined
  509. this.queryParam.productTypeSn1 = ''
  510. this.queryParam.productTypeSn2 = ''
  511. this.queryParam.productTypeSn3 = ''
  512. this.productType = []
  513. this.$refs.table.refresh(true)
  514. },
  515. // 重置已选产品列表
  516. resetChooseSearchForm () {
  517. this.queryChooseParam.productName = ''
  518. this.queryChooseParam.productCode = ''
  519. this.$refs.chooseTable.refresh(true)
  520. },
  521. // 打印预览/快捷打印
  522. handlePrint (type, printerType) {
  523. const _this = this
  524. _this.spinning = true
  525. const url = sparePartsPurDetailPrint
  526. const params = { sn: this.$route.params.sn, type: printerType }
  527. // 打印或导出
  528. hdPrint(printerType, type, url, params, '散件入库', function () {
  529. _this.spinning = false
  530. })
  531. },
  532. // 双击快速添加
  533. handleClickRow (record) {
  534. this.handleAdd(record)
  535. },
  536. // 基本信息
  537. getDetail () {
  538. sparePartsPurDetail({ id: this.$route.params.id }).then(res => {
  539. if (res.status == 200) {
  540. this.basicInfoData = res.data
  541. } else {
  542. this.basicInfoData = null
  543. }
  544. })
  545. },
  546. // 添加/编辑
  547. handleAdd (row, isEdit) {
  548. const _this = this
  549. if (!isEdit && !(row.putCost || row.putCost == 0)) {
  550. this.$message.warning('请输入成本价后再添加!')
  551. return
  552. }
  553. if (!isEdit && !row.putQty) {
  554. this.$message.warning('请输入数量后再添加!')
  555. return
  556. }
  557. if (!isEdit && !row.warehouseSn) {
  558. this.$message.warning('请选择仓库后再添加!')
  559. return
  560. }
  561. if (!isEdit && !row.warehouseLocationSn) {
  562. this.$message.warning('请选择仓位后再添加!')
  563. return
  564. }
  565. if (!isEdit && row.enabledFlag == '0') {
  566. _this.$confirm({
  567. title: '提示',
  568. content: '该产品已禁用,确认继续添加吗?',
  569. centered: true,
  570. onOk () {
  571. _this.saveFormData(row, isEdit)
  572. }
  573. })
  574. return
  575. }
  576. this.saveFormData(row, isEdit)
  577. },
  578. // 保存
  579. saveFormData (row, isEdit) {
  580. const params = {
  581. id: isEdit ? row.id : undefined,
  582. sparePartsPurchaseSn: this.$route.params.sn,
  583. putCost: row.putCost,
  584. putQty: row.putQty,
  585. productCode: isEdit ? row.productCode : row.code,
  586. productOrigCode: (isEdit ? row.productOrigCode : row.origCode) || undefined,
  587. productSn: row.productSn,
  588. productTypeSn1: row.productTypeSn1,
  589. productTypeSn2: row.productTypeSn2,
  590. productTypeSn3: row.productTypeSn3,
  591. brandSn: isEdit ? row.brandSn : row.productBrandSn,
  592. warehouseLocationSn: row.warehouseLocationSn,
  593. warehouseSn: row.warehouseSn
  594. }
  595. if (isEdit) { // 编辑
  596. // 清空成本价或数量时,值应保持未清空前的值,因成本价和数量都不可为空
  597. if (!(row.putCost || row.putCost == 0)) {
  598. row.putCost = row.putCostBackups
  599. return
  600. }
  601. if (!row.putQty) {
  602. row.putQty = row.putQtyBackups
  603. return
  604. }
  605. }
  606. this.spinning = true
  607. sparePartsPurDetailSave(params).then(res => {
  608. if (res.status == 200) {
  609. this.$message.success(res.message)
  610. this.$refs.chooseTable.refresh()
  611. this.spinning = false
  612. } else {
  613. this.spinning = false
  614. }
  615. this.paramsData = null
  616. this.showNewProduct = false
  617. })
  618. },
  619. // 提交
  620. handleSubmit () {
  621. const _this = this
  622. _this.spinning = true
  623. sparePartsPurSubmit({ id: this.$route.params.id }).then(res => {
  624. if (res.status == 200) {
  625. this.$message.success(res.message)
  626. setTimeout(() => {
  627. _this.handleBack()
  628. _this.spinning = false
  629. }, 1000)
  630. } else {
  631. _this.spinning = false
  632. }
  633. })
  634. },
  635. // 删除
  636. handleDel (row) {
  637. const _this = this
  638. this.$confirm({
  639. title: '提示',
  640. content: '删除后不可恢复,确定要进行删除吗?',
  641. centered: true,
  642. closable: true,
  643. onOk () {
  644. _this.spinning = true
  645. sparePartsPurDetailDel({ id: row.id }).then(res => {
  646. if (res.status == 200) {
  647. _this.$message.success(res.message)
  648. _this.$refs.chooseTable.refresh()
  649. _this.spinning = false
  650. } else {
  651. _this.spinning = false
  652. }
  653. })
  654. }
  655. })
  656. },
  657. // 清空列表
  658. delBulkOrder () {
  659. const _this = this
  660. this.$confirm({
  661. title: '提示',
  662. content: '删除后不可恢复,确认要清空已选产品列表吗?',
  663. centered: true,
  664. closable: true,
  665. onOk () {
  666. _this.spinning = true
  667. sparePartsPurDeleteAll({ sn: _this.$route.params.sn }).then(res => {
  668. if (res.status == 200) {
  669. _this.$message.success(res.message)
  670. _this.$refs.chooseTable.refresh()
  671. }
  672. _this.spinning = false
  673. })
  674. }
  675. })
  676. },
  677. // 返回列表
  678. handleBack () {
  679. this.$router.push({ path: '/bulkManagement/bulkWarehousingOrder/list' })
  680. },
  681. // 合计
  682. getDetailCount (params) {
  683. sparePartsPurDetailCount(params).then(res => {
  684. if (res.status == 200) {
  685. this.productTotal = res.data
  686. } else {
  687. this.productTotal = null
  688. }
  689. })
  690. },
  691. changeWarehouseCascade (val, opt, ind, type) {
  692. let loadData
  693. if (type == 'dealerProduct') { // 全部产品
  694. loadData = this.loadDataSource[ind]
  695. } else if (type == 'sparePartsPurDetail') { // 已选产品
  696. loadData = this.chooseLoadDataSource[ind]
  697. }
  698. if (val.length < 2) {
  699. this.$message.warning('当前仓库无仓位,请选择其他仓库')
  700. const warehouseSnBackups = loadData.warehouseSnBackups || undefined
  701. const warehouseLocationSnBackups = loadData.warehouseLocationSnBackups || undefined
  702. loadData.warehouseSn = warehouseSnBackups
  703. loadData.warehouseLocationSn = warehouseLocationSnBackups
  704. if (warehouseSnBackups || warehouseLocationSnBackups) {
  705. loadData.warehouseCascade = [warehouseSnBackups, warehouseLocationSnBackups]
  706. } else {
  707. loadData.warehouseCascade = undefined
  708. }
  709. } else {
  710. loadData.warehouseSn = val[0] ? val[0] : ''
  711. loadData.warehouseLocationSn = val[1] ? val[1] : ''
  712. if (type == 'sparePartsPurDetail') { // 已选产品
  713. loadData = this.chooseLoadDataSource[ind]
  714. this.handleAdd(loadData, 'edit')
  715. }
  716. }
  717. },
  718. // 已选产品 成本价 blur
  719. putCostBlur (val, record) {
  720. // 光标移出,值发生改变再调用编辑接口
  721. if (val != record.putCostBackups || !val) {
  722. this.handleAdd(record, 'edit')
  723. }
  724. },
  725. // 已选产品 数量 blur
  726. putQtyBlur (val, record) {
  727. if (val != record.putQtyBackups) {
  728. this.handleAdd(record, 'edit')
  729. }
  730. },
  731. // 产品分类 change
  732. changeProductType (val, opt) {
  733. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  734. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  735. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  736. },
  737. // 仓库仓位 级联 列表
  738. getWarehouseCascade () {
  739. const _this = this
  740. warehouseCascadeList({}).then(res => {
  741. if (res.status == 200) {
  742. res.data.filter(item => {
  743. // 过滤默认仓库
  744. if (item.defaultFlag == 1 && item.wasteFlag == 0) { // defaultFlag为1,且不是废品仓
  745. _this.defaultWarehouseCascade[0] = item.warehouseSn
  746. // 过滤默认仓位
  747. item.warehouseLocationList.filter(subItem => {
  748. if (subItem.defaultFlag == 1 && subItem.wasteFlag == 0) {
  749. _this.defaultWarehouseCascade[1] = subItem.warehouseLocationSn
  750. // _this.$refs.table.refresh(true)
  751. // _this.$refs.chooseTable.refresh(true)
  752. }
  753. })
  754. }
  755. })
  756. res.data.map(item => {
  757. item.sn = item.warehouseSn
  758. if (item.warehouseLocationList) {
  759. item.warehouseLocationList.map(subItem => {
  760. subItem.sn = subItem.warehouseLocationSn
  761. })
  762. }
  763. })
  764. this.warehouseCascadeData = res.data
  765. } else {
  766. this.warehouseCascadeData = []
  767. }
  768. })
  769. },
  770. // 确认导入明细
  771. hanldeImprotOk (obj) {
  772. this.spinning = true
  773. sparePartsPurDetailInsertBatch(obj).then(res => {
  774. if (res.status == 200) {
  775. this.resetChooseSearchForm()
  776. }
  777. this.spinning = false
  778. })
  779. },
  780. initPage () {
  781. this.getWarehouseCascade()
  782. this.getDetail()
  783. this.resetSearchForm()
  784. this.$refs.chooseTable.refresh(true)
  785. this.$refs.searchProductCode.focus()
  786. }
  787. },
  788. mounted () {
  789. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  790. this.initPage()
  791. }
  792. },
  793. activated () {
  794. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  795. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  796. this.initPage()
  797. }
  798. },
  799. beforeRouteEnter (to, from, next) {
  800. next(vm => {})
  801. }
  802. }
  803. </script>
  804. <style lang="less">
  805. .bulkWarehousingOrderEdit-wrap{
  806. position: relative;
  807. height: 100%;
  808. padding-bottom: 51px;
  809. box-sizing: border-box;
  810. >.ant-spin-nested-loading{
  811. overflow-y: auto;
  812. height: 100%;
  813. }
  814. .bulkWarehousingOrderEdit-cont{
  815. margin-bottom: 10px;
  816. .sub-title{
  817. font-size: 12px;
  818. color: #808695;
  819. margin-left: 10px;
  820. }
  821. }
  822. .rightPrice.ant-input-number-sm input{
  823. text-align: right;
  824. }
  825. .ant-collapse .ant-collapse-item-disabled > .ant-collapse-header{
  826. color:#333;
  827. }
  828. }
  829. </style>