edit.vue 34 KB

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