edit.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. <template>
  2. <div v-if="showPage" class="jg-page-wrap purchaseNewOrderEdit-wrap">
  3. <a-page-header :ghost="false" :backIcon="false" class="header-bar">
  4. <!-- 自定义的二级文字标题 -->
  5. <template slot="subTitle">
  6. <p class="billno">单号:{{ detail&&detail.purchaseBillNo }}</p>
  7. <a-button id="purchaseNewOrderEdit-showDesc-btn" type="link" class="button-default" @click="isShowBisiceInfo=!isShowBisiceInfo" style="margin-left:10px;vertical-align:middle;">
  8. <a-icon :type="isShowBisiceInfo ? 'eye-invisible' : 'eye'"/>
  9. {{ isShowBisiceInfo?'隐藏':'查看' }}信息
  10. </a-button>
  11. <a-button id="purchaseNewOrderEdit-back-btn" type="link" @click="handleBack" class="button-default"> <a-icon type="rollback" /> 返回列表</a-button>
  12. </template>
  13. <!-- 操作区,位于 title 行的行尾 -->
  14. <template slot="extra">
  15. <div style="margin-top: 5px;">
  16. <PrintPanel ref="printBox" v-if="$hasPermissions('B_purchasePrint')" :disabled="localDataSource.length==0" @handlePrint="handlePrint"></PrintPanel>
  17. <a-divider type="vertical" v-if="detail&&detail.totalCategory" />
  18. <a-button type="link" v-if="detail&&detail.totalCategory" @click="showSearch=!showSearch" :class="showSearch?'button-error':'button-default'"> <a-icon type="search" /> 筛选</a-button>
  19. <a-divider type="vertical" v-if="detail&&detail.totalCategory" />
  20. <a-button v-if="detail&&detail.totalCategory" id="purchaseNewOrderEdit-add-btn" type="link" @click="openChooseProduct=true"><a-icon type="plus" />添加产品</a-button>
  21. <a-divider type="vertical" />
  22. <a-dropdown>
  23. <a-menu slot="overlay" @click="handleActions">
  24. <a-menu-item key="3" v-if="$hasPermissions('M_shoppingCart')" id="purchaseNewOrderEdit-more-3">
  25. <a-icon type="shopping" /> 购物车
  26. </a-menu-item>
  27. <a-menu-item key="2" v-if="(systemFlag==0&&!isDealerUp)||(systemFlag==1&&!isDealerUp&&detail&&detail.orderType==='OTHER')" id="purchaseNewOrderEdit-more-2">
  28. <a-icon type="funnel-plot" />导入缺货
  29. </a-menu-item>
  30. <a-menu-item key="1" id="purchaseNewOrderEdit-more-1">
  31. <a-icon type="import" />导入产品
  32. </a-menu-item>
  33. </a-menu>
  34. <a-button id="purchaseNewOrderEdit-more-btn" type="link" class="button-default"> <a-icon type="unordered-list" /> 更多</a-button>
  35. </a-dropdown>
  36. </div>
  37. </template>
  38. </a-page-header>
  39. <!-- 产品列表 -->
  40. <div ref="tableSearch" class="choosedList-cont">
  41. <!-- 基础信息 -->
  42. <div class="baseInfo-bar" v-if="isShowBisiceInfo">
  43. <a-descriptions size="small">
  44. <div slot="title">基础信息</div>
  45. <a-descriptions-item label="供应商">
  46. {{ detail&&detail.purchaseTargetName || '--' }}
  47. </a-descriptions-item>
  48. <a-descriptions-item label="支付方式">
  49. {{ detail&&detail.settleStyleSnDictValue || '--' }}
  50. </a-descriptions-item>
  51. <a-descriptions-item label="收货人">
  52. {{ detail&&detail.consigneeName || '--' }}({{ detail&&detail.consigneeTel || '--' }})
  53. </a-descriptions-item>
  54. <a-descriptions-item label="收货地址" span="3">
  55. <div v-if="detail&&(detail.shippingAddressProvinceName || detail.shippingAddressCityName || detail.shippingAddressCountyName || detail.shippingAddress)">
  56. {{ detail&&detail.shippingAddressProvinceName || '' }}
  57. {{ detail&&detail.shippingAddressCityName || '' }}
  58. {{ detail&&detail.shippingAddressCountyName || '' }}
  59. {{ detail&&detail.shippingAddress || '' }}
  60. <a-button id="purchaseNewOrderEdit-upaddr" type="link" @click="openAddrModal=true">更换地址 >></a-button>
  61. </div>
  62. <div v-else><a-button id="purchaseNewOrderEdit-chooseAddr" type="link" @click="openAddrModal=true">选择地址 >></a-button></div>
  63. </a-descriptions-item>
  64. </a-descriptions>
  65. </div>
  66. <!-- 已选产品 -->
  67. <div class="purchaseTable">
  68. <div class="choosed-table" v-if="detail&&detail.totalCategory">
  69. <!-- 搜索条件 -->
  70. <div class="table-page-search-wrapper" v-if="showSearch">
  71. <a-row :gutter="15">
  72. <a-col :span="24">
  73. <a-form-model :model="productForm" layout="inline" @keyup.enter.native="getTableData()" >
  74. <a-row :gutter="15">
  75. <a-col :md="5" :sm="24">
  76. <a-form-model-item label="产品编码">
  77. <a-input id="purchaseNewOrderEdit-productCode" v-model.trim="productForm.productCode" allowClear placeholder="输入产品编码" />
  78. </a-form-model-item>
  79. </a-col>
  80. <a-col :md="5" :sm="24">
  81. <a-form-model-item label="产品名称">
  82. <a-input id="purchaseNewOrderEdit-productName" v-model.trim="productForm.productName" allowClear placeholder="输入产品名称" />
  83. </a-form-model-item>
  84. </a-col>
  85. <a-col :md="8" :sm="24">
  86. <div style="margin-bottom: 10px;">
  87. <a-button type="primary" @click="getTableData()" :disabled="purchaseDisabled" id="purchaseNewOrderEdit-refresh">查询</a-button>
  88. <a-button style="margin-left: 5px" @click="resetPurchaseForm" id="purchaseNewOrderEdit-reset">重置</a-button>
  89. </div>
  90. </a-col>
  91. </a-row>
  92. </a-form-model>
  93. </a-col>
  94. </a-row>
  95. </div>
  96. <!-- 列表 -->
  97. <a-spin :spinning="spinning" tip="Loading...">
  98. <ve-table
  99. border-y
  100. :border-around="false"
  101. :max-height="tableHeight"
  102. :row-style-option="{clickHighlight: true}"
  103. :cellSelectionOption="{enable: false}"
  104. :virtual-scroll-option="{enable: true}"
  105. :columns="chooseColumns"
  106. :table-data="localDataSource"
  107. row-key-field-name="id"
  108. />
  109. </a-spin>
  110. </div>
  111. <div class="choosed-table" v-else>
  112. <div v-if="!spinning&&localDataSource.length==0">
  113. <a-empty
  114. :image="simpleImage"
  115. :image-style="{
  116. height: '60px',
  117. }"
  118. >
  119. <span slot="description">暂无产品</span>
  120. <a-button id="purchaseNewOrderEdit-go-add" type="primary" class="button-error" @click="openChooseProduct=true"><a-icon type="plus" />立即添加产品</a-button>
  121. </a-empty>
  122. </div>
  123. <div style="text-align: center;padding: 30px 50px;" v-if="spinning">
  124. <a-spin :spinning="spinning" tip="Loading..."></a-spin>
  125. </div>
  126. </div>
  127. </div>
  128. <!-- 底部栏 -->
  129. <div class="footer-bar" v-if="detail&&detail.totalCategory">
  130. <!-- 总计 -->
  131. <div>
  132. <div style="display: inline-block;">
  133. 产品总款数:<span style="color:#666">{{ detail && (detail.totalCategory || detail.totalCategory==0) ? detail.totalCategory : '--' }}</span>,
  134. 采购总数量:<span style="color:#666">{{ detail && (detail.totalQty || detail.totalQty==0) ? detail.totalQty : '--' }}</span>,
  135. </div>
  136. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  137. 采购金额合计: <strong>{{ detail && (detail.discountedAmount || detail.discountedAmount==0) ?toThousands(detail.discountedAmount, 2) : '--' }}</strong>
  138. </div>
  139. </div>
  140. <div>
  141. <a-button
  142. type="primary"
  143. id="purchaseNewOrderEdit-submit-btn"
  144. size="large"
  145. class="button-primary"
  146. :loading="subLoading"
  147. @click="handleSubmit"
  148. style="padding: 0 60px;">提交</a-button>
  149. </div>
  150. </div>
  151. </div>
  152. <!-- 导入产品 -->
  153. <importGuideModal :openModal="openGuideModal" :params="{purchaseBillSn: $route.params.sn}" @close="openGuideModal=false" @ok="hanldeOks" />
  154. <!-- 选择地址 -->
  155. <choose-address-modal :openModal="openAddrModal" @ok="handleAddrOk" @close="openAddrModal=false" />
  156. <!-- 添加产品 -->
  157. <chooseProductModal
  158. ref="chooseProduct"
  159. :isDealerUp="isDealerUp"
  160. :purchaseBillSn="$route.params.sn"
  161. :showModal="openChooseProduct"
  162. @close="openChooseProduct=false"
  163. @add="handleAdd"
  164. ></chooseProductModal>
  165. <!-- 导入缺货 -->
  166. <outStockListModal ref="outStockList" :openModal="openOutStockListModal" @close="openOutStockListModal=false" @ok="hanldeOkOutStockList"></outStockListModal>
  167. <!-- 上次缺货 -->
  168. <outStockModal
  169. ref="outStock"
  170. :paramsSn="$route.params.sn"
  171. :chooseData="chooseData"
  172. :orderType="detail&&detail.orderType"
  173. :openModal="openOutStockModal"
  174. @close="openOutStockModal=false"
  175. @ok="hanldeOkOutStock" />
  176. <!-- 购物车 -->
  177. <shopingCatModal
  178. :showModal="openShopCatModal"
  179. :orderType="detail&&detail.orderType"
  180. :paramsData="paramsData"
  181. @close="openShopCatModal=false"
  182. @ok="getOrderDetail(false, true)"></shopingCatModal>
  183. </div>
  184. </template>
  185. <script>
  186. import { Empty } from 'ant-design-vue'
  187. import { commonMixin } from '@/utils/mixin'
  188. import { STable, VSelect } from '@/components'
  189. import ImportGuideModal from './importGuideModal.vue'
  190. import outStockModal from './outStockModal.vue'
  191. import outStockListModal from './outStockListModal.vue'
  192. import chooseAddressModal from '@/views/common/receivingAddress/chooseAddressModal.vue'
  193. // 接口
  194. import { purchaseDetailBySn, purchaseWriteSubmit, purchaseDetailPrint, purchaseDetailExport, purchaseDetailAddress } from '@/api/purchase'
  195. import { purchaseDetailList, purchaseDetailSave, purchaseDetailDel } from '@/api/purchaseDetail'
  196. import { getParamValue } from '@/api/data'
  197. // 选择产品
  198. import chooseProductModal from './chooseProductModal.vue'
  199. // 打印
  200. import PrintPanel from '@/views/common/printPanel.vue'
  201. import { hdPrint } from '@/libs/JGPrint'
  202. // 异步加载购物车弹框
  203. const shopingCatModal = () => import(/* webpackChunkName: "shopingCatModal" */ '@/views/common/shopingCatModal.vue')
  204. // 自定义数量组件
  205. const qtyComp = {
  206. name: 'qtyComp',
  207. template: `
  208. <a-input-number
  209. size="small"
  210. v-model="row.qty"
  211. :id="'purchaseNewOrderEdit-editQty-'+row.id"
  212. :precision="0"
  213. :min="1"
  214. :max="999999"
  215. @blur="e => that.qtyBlur(e.target.value, row)"
  216. style="width: 100%;"
  217. placeholder="请输入" />
  218. `,
  219. props: {
  220. row: Object,
  221. column: Object,
  222. rowIndex: Number,
  223. that: Object
  224. }
  225. }
  226. // 自定义操作组件
  227. const actionComp = {
  228. name: 'actionComp',
  229. template: `
  230. <a-button
  231. size="small"
  232. type="link"
  233. :id="'purchaseNewOrderEdit-del-'+row.id"
  234. class="button-error"
  235. :loading="row.delLoading"
  236. @click="that.handleDel(row)"
  237. >删除</a-button>
  238. `,
  239. props: {
  240. row: Object,
  241. column: Object,
  242. rowIndex: Number,
  243. that: Object
  244. }
  245. }
  246. export default {
  247. name: 'PurchaseEdit',
  248. components: { STable, VSelect, ImportGuideModal, outStockModal, PrintPanel, chooseAddressModal, chooseProductModal, shopingCatModal, outStockListModal },
  249. mixins: [commonMixin],
  250. data () {
  251. return {
  252. isShowBisiceInfo: false, // 是否显示详情信息
  253. showPage: false, // 是否显示页面
  254. spinning: false,
  255. detail: null, // 详细信息
  256. openChooseProduct: false, // 打开添加产品弹框
  257. openShopCatModal: false, // 打开购物车弹框
  258. tableHeight: 0, // 表格高度
  259. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE, // 默认图片
  260. // -------已选产品-------------
  261. subLoading: false, // loading加载
  262. orderCountData: null, // 统计信息
  263. delLoading: false, // 操作按钮loading加载
  264. showSearch: false, // 是否查询
  265. productForm: {
  266. productName: '', // 产品名称
  267. productCode: '', // 产品编码
  268. orderBy: 'purchase_bill_detail.CREATE_DATE desc' // 默认排序
  269. },
  270. purchaseDisabled: false, // 查询、重置按钮是否可操作
  271. localDataSource: [], // 原始列表数据
  272. chooseData: [], // 已选列表数据
  273. openGuideModal: false, // 导入产品引导
  274. openOutStockModal: false, // 上次缺货弹框
  275. paramsData: null, // 传递购物车的参数
  276. openAddrModal: false, // 选择地址弹框是否显示
  277. openOutStockListModal: false, // 导入缺货
  278. systemFlag: null// 是否是转单产品
  279. }
  280. },
  281. computed: {
  282. // 是否上级经销商
  283. isDealerUp () {
  284. return this.detail && (this.detail.purchaseTargetType == 'DEALER_UP' || this.detail.purchaseTargetType == 'DEALER_SUPPLIER')
  285. },
  286. // 已选列表列
  287. chooseColumns () {
  288. const _this = this
  289. const arr = [
  290. { title: '序号', key: 'a', field: 'no', width: '5%', align: 'center', operationColumn: false },
  291. { title: '产品编码', key: 'b', field: 'productCode', width: '10%', align: 'center', operationColumn: false },
  292. { title: '产品名称', key: 'c', field: 'productName', width: '25%', align: 'left', operationColumn: false, ellipsis: { showTitle: true } },
  293. { title: '原厂编码', key: 'q', field: 'productOrgCode', width: '15%', align: 'center', operationColumn: false },
  294. { title: '可用库存', key: 'j', field: 'currentStockQty', width: '10%', align: 'center', operationColumn: false },
  295. { title: '采购数量',
  296. key: 'd',
  297. width: '10%',
  298. align: 'center',
  299. operationColumn: false,
  300. renderBodyCell: ({ row, column, rowIndex }, h) => {
  301. return <qtyComp row={row} column={column} rowIndex={rowIndex} that={_this} />
  302. } },
  303. { title: '单位', key: 'e', field: 'productUnit', width: '10%', align: 'center', operationColumn: false },
  304. { title: '操作',
  305. key: 'f',
  306. width: '10%',
  307. align: 'center',
  308. operationColumn: false,
  309. renderBodyCell: ({ row, column, rowIndex }, h) => {
  310. return <actionComp row={row} column={column} rowIndex={rowIndex} that={_this} />
  311. } }
  312. ]
  313. // 是否有成本价权限
  314. if (this.$hasPermissions('M_ShowAllCost')) {
  315. arr.splice(4, 0, { title: '采购单价', key: 'h', field: 'discountedPriceText', width: '10%', align: 'right', operationColumn: false })
  316. arr.splice(6, 0, { title: '采购金额', key: 'i', field: 'discountedAmountText', width: '10%', align: 'right', operationColumn: false })
  317. }
  318. return arr
  319. }
  320. },
  321. methods: {
  322. // 更多操作
  323. handleActions (e) {
  324. // 导入
  325. if (e.key == 1) {
  326. this.openGuideModal = true
  327. }
  328. // 缺货
  329. if (e.key == 2) {
  330. this.handleOutStock()
  331. }
  332. // 购物车
  333. if (e.key == 3) {
  334. this.hanldCart()
  335. }
  336. },
  337. // 获取列表数据
  338. getTableData () {
  339. this.disabled = true
  340. this.spinning = true
  341. // 查询总计
  342. const params = Object.assign({ pageNo: 1, pageSize: 10000 }, this.productForm, { purchaseBillSn: this.$route.params.sn })
  343. purchaseDetailList(params).then(res => {
  344. const data = res.data
  345. const no = (data.pageNo - 1) * data.pageSize
  346. for (var i = 0; i < data.list.length; i++) {
  347. const row = data.list[i]
  348. row.no = no + i + 1
  349. row.qtyBackups = row.qty
  350. row.productCode = row.dealerProductEntity.code || '--'
  351. row.productName = row.dealerProductEntity.name || '--'
  352. row.productUnit = row.dealerProductEntity.unit || '--'
  353. row.discountedPriceText = (row.discountedPrice || row.discountedPrice == 0) ? this.toThousands(row.discountedPrice, 2) : '--'
  354. row.discountedAmountText = (row.discountedAmount || row.discountedAmount == 0) ? this.toThousands(row.discountedAmount, 2) : '--'
  355. row.currentStockQty = (row.currentStockQty || row.currentStockQty == 0) ? row.currentStockQty : '--'
  356. row.productOrgCode = row.dealerProductEntity.origCode || '--'
  357. }
  358. this.localDataSource = data.list
  359. this.disabled = false
  360. this.spinning = false
  361. })
  362. },
  363. // 获取采购单基本信息
  364. getOrderDetail (noRefashTable, isReset, flag) {
  365. this.spinning = true
  366. purchaseDetailBySn({ sn: this.$route.params.sn }).then(res => {
  367. if (res.status == 200) {
  368. this.detail = res.data
  369. if (!noRefashTable) {
  370. // 如果有列表数据
  371. if (this.detail.totalCategory) {
  372. if (isReset) {
  373. this.resetPurchaseForm()
  374. } else {
  375. this.getTableData()
  376. }
  377. } else {
  378. this.localDataSource = []
  379. this.spinning = false
  380. }
  381. } else {
  382. this.spinning = false
  383. }
  384. } else {
  385. this.spinning = false
  386. }
  387. })
  388. },
  389. // 删除产品
  390. handleDel (row) {
  391. const _this = this
  392. this.$confirm({
  393. title: '提示',
  394. content: '确认要删除吗?',
  395. centered: true,
  396. closable: true,
  397. onOk () {
  398. row.delLoading = true
  399. purchaseDetailDel({ id: row.id }).then(res => {
  400. if (res.status == 200) {
  401. _this.getOrderDetail(false, false, true)
  402. _this.$message.success(res.message)
  403. row.delLoading = false
  404. } else {
  405. row.delLoading = false
  406. }
  407. })
  408. }
  409. })
  410. },
  411. // 修改数量后
  412. qtyBlur (val, record) {
  413. // 光标移出,值发生改变再调用编辑接口
  414. if (val != record.qtyBackups) {
  415. this.handleAdd(record, 1)
  416. }
  417. },
  418. // 重置已选产品列表
  419. resetPurchaseForm () {
  420. this.productForm.productName = ''
  421. this.productForm.productCode = ''
  422. this.$nextTick(() => {
  423. this.getTableData()
  424. })
  425. },
  426. // 添加或修改
  427. handleAdd (row, type) {
  428. let params = {}
  429. if (type == 0 && !row.qty) {
  430. this.$message.warning('请输入数量后再添加!')
  431. this.$refs.chooseProduct.spinning = false
  432. return
  433. }
  434. // 添加
  435. if (type == 0) {
  436. // 是上级
  437. if (this.isDealerUp) {
  438. // 如果有成本价
  439. if (row.purchasePrice) {
  440. params.productSn = row.productSn
  441. params.purchaseBillSn = this.detail.purchaseBillSn
  442. params.purchaseBillNo = this.detail.purchaseBillNo
  443. params.price = row.purchasePrice
  444. params.qty = row.qty
  445. params.priceLevel = row.priceLevel
  446. } else {
  447. this.$message.warning('成本价不能为空!(注:请联系【供应商】完善定价)')
  448. this.$refs.chooseProduct.spinning = false
  449. return
  450. }
  451. } else {
  452. // 如果有成本价、终端会员价、车主零售价
  453. if (row.purchasePrice && row.terminalPrice && row.carOwnersPrice) {
  454. params.productSn = row.productSn
  455. params.purchaseBillSn = this.detail.purchaseBillSn
  456. params.purchaseBillNo = this.detail.purchaseBillNo
  457. params.price = row.purchasePrice
  458. params.qty = row.qty
  459. params.priceLevel = row.priceLevel
  460. } else {
  461. this.$message.warning('成本价、终端会员价、车主零售价不能为空!(注:请联系【供应商】完善定价)')
  462. this.$refs.chooseProduct.spinning = false
  463. return
  464. }
  465. }
  466. } else { // 编辑
  467. // 清空成本价或数量时,值应保持未清空前的值,因成本价和数量都不可为空
  468. if (!row.qty) {
  469. row.qty = row.qtyBackups
  470. return
  471. }
  472. params = row
  473. }
  474. this.addLoading = true
  475. purchaseDetailSave(params).then(res => {
  476. if (res.status == 200) {
  477. this.getOrderDetail(false, true, true)
  478. this.$message.success(res.message)
  479. if (type == 0) {
  480. row.qtyBackups = row.qty
  481. }
  482. } else {
  483. row.qty = row.qtyBackups
  484. }
  485. this.addLoading = false
  486. this.$refs.chooseProduct.spinning = false
  487. })
  488. },
  489. // 提交
  490. handleSubmit () {
  491. const _this = this
  492. if (_this.detail && !_this.detail.totalCategory) {
  493. this.$message.info('请添加产品')
  494. return false
  495. }
  496. this.subLoading = true
  497. purchaseWriteSubmit({ id: this.detail.id }).then(res => {
  498. if (res.status == 200) {
  499. if (res.data && res.data.length > 0) {
  500. const resTips = res.data.join('、')
  501. this.$confirm({
  502. title: '提示',
  503. content: resTips + '暂不销售,请删除后重新提交采购单',
  504. centered: true,
  505. okText: '知道了',
  506. cancelText: '取消', // 将cancelText设置为空字符串或去掉该属性可以隐藏取消按钮
  507. cancelButtonProps: {
  508. style: {
  509. display: 'none' // 通过设置样式隐藏取消按钮
  510. }
  511. },
  512. onOk () {
  513. console.log('知道了')
  514. }
  515. })
  516. } else {
  517. this.$message.success(res.message)
  518. setTimeout(() => {
  519. _this.handleBack()
  520. }, 1000)
  521. }
  522. }
  523. _this.subLoading = false
  524. })
  525. },
  526. // 导入产品
  527. hanldeOks () {
  528. this.getOrderDetail(false, true, true)
  529. },
  530. // 打开购物车
  531. hanldCart () {
  532. this.paramsData = {
  533. purchaseBillSn: this.$route.params.sn,
  534. purchaseBillNo: this.detail && this.detail.purchaseBillNo ? this.detail.purchaseBillNo : undefined,
  535. orderType: this.detail && this.detail.orderType ? this.detail.orderType : undefined
  536. }
  537. this.openShopCatModal = true
  538. },
  539. // 上次缺货
  540. handleOutStock () {
  541. this.openOutStockListModal = true
  542. const _this = this
  543. _this.$nextTick(() => {
  544. _this.$refs.outStockList.resetSearchForm()
  545. })
  546. },
  547. // 地址保存
  548. handleAddrOk (data) {
  549. const params = {
  550. purchaseBillSn: this.$route.params.sn,
  551. shippingAddressProvinceName: data.provinceName,
  552. shippingAddressCityName: data.cityName,
  553. shippingAddressCountyName: data.countyName,
  554. shippingAddress: data.addr,
  555. consigneeName: data.consigneeName,
  556. consigneeTel: data.consigneeTel
  557. }
  558. purchaseDetailAddress(params).then(res => {
  559. if (res.status == 200) {
  560. this.openAddrModal = false
  561. this.getOrderDetail(true)
  562. }
  563. })
  564. },
  565. // 选择缺货列表 打开上次缺货列表
  566. hanldeOkOutStockList (con) {
  567. const _this = this
  568. _this.openOutStockModal = true
  569. _this.chooseData = con
  570. _this.$nextTick(() => {
  571. _this.$refs.outStock.resetSearchForm()
  572. })
  573. },
  574. // 上次缺货 导入成功
  575. hanldeOkOutStock () {
  576. this.getOrderDetail(false, true, true)
  577. this.chooseData = null
  578. this.openOutStockModal = false
  579. this.openOutStockListModal = false
  580. },
  581. // 打印预览/快捷打印
  582. handlePrint (type, printerType) {
  583. const _this = this
  584. if (type == 'preview') {
  585. _this.openChooseProduct = false
  586. _this.openOutStockModal = false
  587. }
  588. _this.spinning = true
  589. let url = purchaseDetailPrint
  590. let params = { sn: this.$route.params.sn, type: printerType }
  591. if (type == 'export') { // 导出
  592. url = purchaseDetailExport
  593. params = { sn: this.$route.params.sn }
  594. }
  595. // 打印或导出
  596. hdPrint(printerType, type, url, params, '采购单', function () {
  597. _this.spinning = false
  598. _this.$refs.printBox.hovered = false
  599. })
  600. },
  601. // 获取系统参数 判断是否显示产品类型
  602. getSystemInfo () {
  603. getParamValue({ code: 'TIRE_OPEN' }).then(res => {
  604. if (res.status == 200) {
  605. this.systemFlag = res.data
  606. }
  607. })
  608. },
  609. // 返回列表
  610. handleBack () {
  611. this.$router.push({ name: 'purchaseOrderNewList' })
  612. },
  613. // 计算表格高度
  614. setTableH () {
  615. this.tableHeight = window.innerHeight - (this.isShowBisiceInfo ? 127 : 0) - (this.showSearch ? 42 : 0) - 210
  616. },
  617. // 页面初始化
  618. pageInit () {
  619. this.$nextTick(() => {
  620. this.setTableH()
  621. this.getOrderDetail(false, true)
  622. })
  623. this.getSystemInfo()
  624. }
  625. },
  626. watch: {
  627. // 显示详情信息
  628. isShowBisiceInfo (newValue, oldValue) {
  629. this.setTableH()
  630. },
  631. // 显示页面
  632. showSearch (newValue, oldValue) {
  633. if (this.isShowBisiceInfo) {
  634. this.isShowBisiceInfo = false
  635. } else {
  636. this.setTableH()
  637. }
  638. },
  639. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  640. this.setTableH()
  641. }
  642. },
  643. mounted () {
  644. this.showPage = true
  645. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  646. this.pageInit()
  647. }
  648. },
  649. activated () {
  650. this.showPage = true
  651. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  652. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  653. this.pageInit()
  654. }
  655. },
  656. beforeRouteEnter (to, from, next) {
  657. next(vm => {})
  658. }
  659. }
  660. </script>
  661. <style lang="less">
  662. .purchaseNewOrderEdit-wrap{
  663. position: relative;
  664. height: 100%;
  665. box-sizing: border-box;
  666. .choosedList-cont{
  667. position: relative;
  668. background-color: #fff;
  669. height: calc(100% - 60px);
  670. }
  671. }
  672. </style>