edit.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. <template>
  2. <div v-if="showPage" class="purchaseOrderEdit-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="purchaseOrderEdit-cont">
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="purchaseOrderEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <p class="billno">单号:{{ detail&&detail.purchaseBillNo }}</p>
  9. </template>
  10. <!-- 操作区,位于 title 行的行尾 -->
  11. <template slot="extra" v-if="$hasPermissions('B_purchasePrint')">
  12. <Print :disabled="localDataSource.length==0" @handlePrint="handlePrint"></Print>
  13. </template>
  14. </a-page-header>
  15. <!-- 基础信息 -->
  16. <a-card size="small" :bordered="false" class="purchaseOrderEdit-cont">
  17. <a-collapse :activeKey="['1']">
  18. <a-collapse-panel key="1">
  19. <template slot="header">
  20. 基础信息
  21. </template>
  22. <a-descriptions :column="2">
  23. <a-descriptions-item label="供应商">{{ detail&&detail.purchaseTargetName || '--' }}</a-descriptions-item>
  24. <a-descriptions-item label="支付方式">{{ detail&&detail.settleStyleSnDictValue || '--' }}</a-descriptions-item>
  25. <a-descriptions-item label="收货人">{{ detail&&detail.consigneeName || '--' }}({{ detail&&detail.consigneeTel || '--' }})</a-descriptions-item>
  26. <a-descriptions-item label="收货地址">
  27. <div v-if="detail&&(detail.shippingAddressProvinceName || detail.shippingAddressCityName || detail.shippingAddressCountyName || detail.shippingAddress)">
  28. {{ detail&&detail.shippingAddressProvinceName || '' }}
  29. {{ detail&&detail.shippingAddressCityName || '' }}
  30. {{ detail&&detail.shippingAddressCountyName || '' }}
  31. {{ detail&&detail.shippingAddress || '' }}
  32. <a-button type="link" @click="openAddrModal=true">更换地址 >></a-button>
  33. </div>
  34. <p v-else><a-button type="link" @click="openAddrModal=true">选择地址 >></a-button></p>
  35. </a-descriptions-item>
  36. </a-descriptions>
  37. </a-collapse-panel>
  38. </a-collapse>
  39. </a-card>
  40. <!-- 选择产品 -->
  41. <a-card size="small" :bordered="false" class="purchaseOrderEdit-cont">
  42. <a-collapse :activeKey="['1']">
  43. <a-collapse-panel key="1">
  44. <template slot="header">
  45. <div style="display: flex;">
  46. 选择产品<span class="sub-title">①输入查询条件--->②查找到需要采购的产品--->③录入采购数量--->④点击“添加”</span>
  47. <p class="tag-txt">注意:仅限采购【箭冠】产品。自建产品的采购入库请使用“散件入库”功能</p>
  48. </div>
  49. </template>
  50. <!-- 选择产品 -->
  51. <div>
  52. <!-- 搜索条件 -->
  53. <div class="table-page-search-wrapper">
  54. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  55. <a-row :gutter="15">
  56. <a-col :md="4" :sm="24">
  57. <a-form-model-item label="产品编码">
  58. <a-input id="purchaseOrderEdit-code" ref="searchProductCode" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
  59. </a-form-model-item>
  60. </a-col>
  61. <a-col :md="4" :sm="24">
  62. <a-form-model-item label="产品名称">
  63. <a-input id="purchaseOrderEdit-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
  64. </a-form-model-item>
  65. </a-col>
  66. <a-col :md="4" :sm="24">
  67. <a-form-model-item label="原厂编码">
  68. <a-input id="purchaseOrderEdit-origCode" v-model.trim="queryParam.origCode" allowClear placeholder="请输入原厂编码"/>
  69. </a-form-model-item>
  70. </a-col>
  71. <a-col :md="4" :sm="24">
  72. <a-form-item label="产品分类">
  73. <ProductType id="purchaseOrderEdit-productType" @change="changeProductType" v-model="productType"></ProductType>
  74. </a-form-item>
  75. </a-col>
  76. <template v-if="advanced">
  77. <a-col :md="4" :sm="24">
  78. <a-form-item label="产品品牌">
  79. <ProductBrand id="purchaseOrderEdit-productBrand" v-model="queryParam.productBrandSn"></ProductBrand>
  80. </a-form-item>
  81. </a-col>
  82. </template>
  83. <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
  84. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="purchaseOrderEdit-refresh">查询</a-button>
  85. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="purchaseOrderEdit-reset">重置</a-button>
  86. <a @click="advanced=!advanced" style="margin:0 30px 0 10px">
  87. {{ advanced ? '收起' : '展开' }}
  88. <a-icon :type="advanced ? 'up' : 'down'"/>
  89. </a>
  90. </a-col>
  91. </a-row>
  92. </a-form>
  93. </div>
  94. <!-- 列表 -->
  95. <s-table
  96. class="sTable"
  97. ref="table"
  98. size="small"
  99. :rowKey="(record) => record.id"
  100. :columns="columns"
  101. :data="loadData"
  102. :defaultLoadData="false"
  103. :scroll="{ y:176 }"
  104. :pageSize="10"
  105. bordered>
  106. <!-- 产品图片 -->
  107. <template slot="imageUrl" slot-scope="text, record">
  108. <img
  109. :src="record.productMainPic && record.productMainPic.imageUrl?(record.productMainPic.imageUrl+'?x-oss-process=image/resize,h_30,m_lfit'):defImg"
  110. width="30"
  111. height="30"
  112. style="cursor: pointer;"
  113. @click="handlePicDetail(record)" />
  114. </template>
  115. <!-- 包装数 -->
  116. <template slot="baozh" slot-scope="text, record">
  117. {{ record.packQty||'--' }}/{{ record.packQtyUnit||'--' }}
  118. </template>
  119. <!-- 产品编码 -->
  120. <template slot="code" slot-scope="text, record">
  121. <a-tooltip placement="top" v-if="record.stockState=='NOT_ENOUGH'">
  122. <template slot="title">
  123. 该产品暂时缺货!
  124. </template>
  125. <span class="noStock">{{ record.code || '--' }}</span>
  126. </a-tooltip>
  127. <span v-else>{{ record.code || '--' }}</span>
  128. </template>
  129. <!-- 采购数量 -->
  130. <template slot="storageQuantity" slot-scope="text, record">
  131. <a-input-number
  132. size="small"
  133. v-model="record.qty"
  134. :precision="0"
  135. :min="0"
  136. :max="999999"
  137. style="width: 100%;"
  138. placeholder="请输入数量" />
  139. </template>
  140. <!-- 操作 -->
  141. <template slot="action" slot-scope="text, record">
  142. <a-button
  143. size="small"
  144. type="link"
  145. class="button-primary"
  146. :loading="addLoading"
  147. @click="handleAdd(record,0)"
  148. v-if="record.purchasePrice>0"
  149. id="purchaseOrderEdit-add-btn">添加</a-button>
  150. <span v-else>--</span>
  151. </template>
  152. </s-table>
  153. </div>
  154. </a-collapse-panel>
  155. </a-collapse>
  156. </a-card>
  157. <!-- 已选产品 -->
  158. <a-card size="small" :bordered="false" class="purchaseOrderEdit-cont">
  159. <a-collapse :activeKey="['1']">
  160. <a-collapse-panel key="1">
  161. <template slot="header">已选产品</template>
  162. <div>
  163. <!-- 总计 -->
  164. <a-alert type="info" style="margin-bottom:10px">
  165. <div slot="message">产品款数 <strong>{{ detail && (detail.totalCategory || detail.totalCategory==0) ? detail.totalCategory : '--' }}</strong> ,
  166. 采购数量合计 <strong>{{ detail && (detail.totalQty || detail.totalQty==0) ? detail.totalQty : '--' }}</strong> ,
  167. 采购金额合计 <strong>{{ detail && (detail.discountedAmount || detail.discountedAmount==0) ? '¥'+detail.discountedAmount : '--' }}</strong></div>
  168. </a-alert>
  169. <!-- 搜索条件 -->
  170. <div class="table-page-search-wrapper">
  171. <a-row :gutter="15">
  172. <a-col :span="18">
  173. <a-form-model :model="productForm" layout="inline" @keyup.enter.native="$refs.purchaseTable.refresh(true)" >
  174. <a-row :gutter="15">
  175. <a-col :md="8" :sm="24">
  176. <a-form-model-item label="产品编码">
  177. <a-input v-model.trim="productForm.productCode" allowClear placeholder="输入产品编码" />
  178. </a-form-model-item>
  179. </a-col>
  180. <a-col :md="8" :sm="24">
  181. <a-form-model-item label="产品名称">
  182. <a-input v-model.trim="productForm.productName" allowClear placeholder="输入产品名称" />
  183. </a-form-model-item>
  184. </a-col>
  185. <a-col :md="8" :sm="24">
  186. <a-form-model-item style="margin-bottom: 10px;">
  187. <a-button type="primary" @click="$refs.purchaseTable.refresh(true)" :disabled="purchaseDisabled" id="purchaseOrderEdit-refresh">查询</a-button>
  188. <a-button style="margin-left: 5px" @click="resetPurchaseForm" id="purchaseOrderEdit-reset">重置</a-button>
  189. </a-form-model-item>
  190. </a-col>
  191. </a-row>
  192. </a-form-model>
  193. </a-col>
  194. <a-col :span="6">
  195. <div style="float:right;overflow: hidden;">
  196. <a-button size="small" type="primary" class="button-primary" id="purchaseOrderEdit-import-btn" @click="handleOutStock">上次缺货</a-button>
  197. <a-button size="small" id="purchaseOrderEdit-import-btn" @click="openGuideModal=true">导入产品</a-button>
  198. </div>
  199. </a-col>
  200. </a-row>
  201. </div>
  202. <!-- 列表 -->
  203. <s-table
  204. class="sTable"
  205. ref="purchaseTable"
  206. size="small"
  207. :rowKey="(record) => record.id"
  208. :columns="chooseColumns"
  209. :data="chooseLoadData"
  210. :defaultLoadData="false"
  211. :showPagination="false"
  212. bordered>
  213. <!-- 采购数量 -->
  214. <template slot="storageQuantity" slot-scope="text, record">
  215. <a-input-number
  216. size="small"
  217. id="purchaseOrderEdit-qty"
  218. v-model="record.qty"
  219. :precision="0"
  220. :min="1"
  221. :max="999999"
  222. @blur="e => qtyBlur(e.target.value, record)"
  223. style="width: 100%;"
  224. placeholder="请输入" />
  225. </template>
  226. <!-- 操作 -->
  227. <template slot="action" slot-scope="text, record">
  228. <a-button
  229. size="small"
  230. type="link"
  231. class="button-error"
  232. :loading="delLoading"
  233. @click="handleDel(record)"
  234. id="purchaseOrderEdit-del-btn">删除</a-button>
  235. </template>
  236. </s-table>
  237. </div>
  238. </a-collapse-panel>
  239. </a-collapse>
  240. </a-card>
  241. </a-spin>
  242. <div class="affix-cont">
  243. <a-button
  244. type="primary"
  245. id="purchaseOrderEdit-submit-btn"
  246. size="large"
  247. class="button-primary"
  248. :loading="subLoading"
  249. :disabled="spinning"
  250. @click="handleSubmit"
  251. style="padding: 0 60px;">提交</a-button>
  252. </div>
  253. <!-- 导入产品 -->
  254. <importGuideModal :openModal="openGuideModal" :params="{purchaseBillSn: $route.params.sn}" @close="openGuideModal=false" @ok="hanldeOks" />
  255. <!-- 上次缺货 -->
  256. <outStockModal :openModal="openOutStockModal" :paramsData="paramsData" @close="openOutStockModal=false" @ok="hanldeOkOutStock" />
  257. <!-- 选择地址 -->
  258. <choose-address-modal :openModal="openAddrModal" @ok="handleAddrOk" @close="openAddrModal=false" />
  259. </div>
  260. </template>
  261. <script>
  262. import { commonMixin } from '@/utils/mixin'
  263. import { STable, VSelect } from '@/components'
  264. import ImportGuideModal from './importGuideModal.vue'
  265. import outStockModal from './outStockModal.vue'
  266. import chooseAddressModal from './receivingAddress/chooseAddressModal.vue'
  267. import ProductType from '../../common/productType.js'
  268. import ProductBrand from '../../common/productBrand.js'
  269. import { purchaseDetailBySn, purchaseWriteSubmit, purchaseDetailPrint, purchaseDetailExport, purchaseDetailAddress } from '@/api/purchase'
  270. import { purchaseDetailList, purchaseDetailSave, purchaseDetailDel, purchaseDetailCount, purchaseDetailCancelList } from '@/api/purchaseDetail'
  271. import { productListPurchase } from '@/api/product'
  272. import defImg from '@/assets/def_img@2x.png'
  273. import Print from '@/views/common/print.vue'
  274. import { hdPrint } from '@/libs/JGPrint'
  275. export default {
  276. name: 'PurchaseEdit',
  277. components: { STable, VSelect, ProductType, ProductBrand, ImportGuideModal, outStockModal, Print, chooseAddressModal },
  278. mixins: [commonMixin],
  279. data () {
  280. return {
  281. showPage: false,
  282. spinning: false,
  283. detail: null, // 详细信息
  284. subLoading: false,
  285. defImg,
  286. // 选择产品
  287. addLoading: false,
  288. productType: [],
  289. queryParam: {
  290. productBrandSn: undefined,
  291. code: '', // 产品编码
  292. name: '', // 产品名称
  293. origCode: '', // 原厂编码
  294. productTypeSn1: '', // 产品一级分类
  295. productTypeSn2: '', // 产品二级分类
  296. productTypeSn3: '' // 产品三级分类
  297. },
  298. typeData: [], // 下拉数据
  299. advanced: false, // 高级搜索 展开/关闭
  300. disabled: false, // 查询、重置按钮是否可操作
  301. // 表头
  302. columns: [
  303. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  304. { title: '产品编码', scopedSlots: { customRender: 'code' }, width: '15%', align: 'center', sorter: true },
  305. { title: '产品名称', dataIndex: 'name', width: '23%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  306. { title: '原厂编码', dataIndex: 'origCode', width: '14%', align: 'center', customRender: function (text) { return text && text != ' ' ? text : '--' } },
  307. { title: '单位', dataIndex: 'unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  308. { title: '包装数', scopedSlots: { customRender: 'baozh' }, width: '5%', align: 'center' },
  309. { title: '成本价', dataIndex: 'purchasePrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  310. { title: '终端会员价', dataIndex: 'terminalPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  311. { title: '车主零售价', dataIndex: 'carOwnersPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  312. { title: '采购数量', dataIndex: 'qty', scopedSlots: { customRender: 'storageQuantity' }, width: '6%', align: 'center' },
  313. { title: '产品图片', scopedSlots: { customRender: 'imageUrl' }, width: '6%', align: 'center' },
  314. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  315. ],
  316. // 加载数据方法 必须为 Promise 对象
  317. loadData: parameter => {
  318. this.disabled = true
  319. return productListPurchase(Object.assign(parameter, this.queryParam, { purchaseBillSn: this.$route.params.sn })).then(res => {
  320. const data = res.data
  321. const no = (data.pageNo - 1) * data.pageSize
  322. for (var i = 0; i < data.list.length; i++) {
  323. data.list[i].no = no + i + 1
  324. data.list[i].qty = 1
  325. }
  326. this.disabled = false
  327. return data
  328. })
  329. },
  330. // -------已选产品-------------
  331. orderCountData: null,
  332. delLoading: false,
  333. productForm: {
  334. productName: '',
  335. productCode: '',
  336. orderBy: 'purchase_bill_detail.CREATE_DATE desc'
  337. },
  338. purchaseDisabled: false, // 查询、重置按钮是否可操作
  339. // 表头
  340. chooseColumns: [
  341. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  342. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '20%', align: 'center' },
  343. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  344. { title: '采购单价', dataIndex: 'discountedPrice', width: '20%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  345. { title: '采购数量', scopedSlots: { customRender: 'storageQuantity' }, width: '10%', align: 'center' },
  346. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  347. { title: '采购金额', dataIndex: 'discountedAmount', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  348. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  349. ],
  350. // 加载数据方法 必须为 Promise 对象
  351. chooseLoadData: parameter => {
  352. this.disabled = true
  353. // 查询总计
  354. // const params = Object.assign(parameter, this.productForm, { purchaseBillSn: this.$route.params.sn })
  355. const params = Object.assign({ pageNo: 1, pageSize: 5000 }, this.productForm, { purchaseBillSn: this.$route.params.sn })
  356. // this.getCountQuery(params)
  357. return purchaseDetailList(params).then(res => {
  358. const data = res.data
  359. const no = (data.pageNo - 1) * data.pageSize
  360. for (var i = 0; i < data.list.length; i++) {
  361. data.list[i].no = no + i + 1
  362. data.list[i].qtyBackups = data.list[i].qty
  363. }
  364. this.localDataSource = data.list
  365. this.disabled = false
  366. return data
  367. })
  368. },
  369. localDataSource: [],
  370. openGuideModal: false, // 导入产品引导
  371. openOutStockModal: false,
  372. paramsData: null,
  373. openAddrModal: false // 选择地址弹框是否显示
  374. }
  375. },
  376. methods: {
  377. // 获取采购单明细统计
  378. getCountQuery (params) {
  379. purchaseDetailCount(params).then(res => {
  380. this.orderCountData = res.data || null
  381. })
  382. },
  383. // 获取采购单基本信息
  384. getOrderDetail () {
  385. purchaseDetailBySn({ sn: this.$route.params.sn }).then(res => {
  386. if (res.status == 200) {
  387. this.detail = res.data
  388. }
  389. })
  390. },
  391. // 删除产品
  392. handleDel (row) {
  393. const _this = this
  394. this.$confirm({
  395. title: '提示',
  396. content: '确认要删除吗?',
  397. centered: true,
  398. closable: true,
  399. onOk () {
  400. _this.delLoading = true
  401. _this.spinning = true
  402. purchaseDetailDel({ id: row.id }).then(res => {
  403. if (res.status == 200) {
  404. _this.resetPurchaseDetail(true)
  405. _this.$message.success(res.message)
  406. _this.delLoading = false
  407. _this.spinning = false
  408. } else {
  409. _this.delLoading = false
  410. _this.spinning = false
  411. }
  412. })
  413. }
  414. })
  415. },
  416. // 重新查询已选产品
  417. resetPurchaseDetail (flag) {
  418. this.$refs.purchaseTable.refresh(!!flag)
  419. this.getOrderDetail()
  420. },
  421. // 修改数量后
  422. qtyBlur (val, record) {
  423. // 光标移出,值发生改变再调用编辑接口
  424. if (val != record.qtyBackups) {
  425. this.handleAdd(record, 1)
  426. }
  427. },
  428. filterOption (input, option) {
  429. return (
  430. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  431. )
  432. },
  433. // 产品分类 change
  434. changeProductType (val, opt) {
  435. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  436. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  437. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  438. },
  439. // 重置产品库
  440. resetSearchForm () {
  441. this.queryParam = {
  442. productBrandSn: undefined,
  443. code: '', // 产品编码
  444. name: '', // 产品名称
  445. origCode: '', // 原厂编码
  446. productTypeSn1: '', // 产品一级分类
  447. productTypeSn2: '', // 产品二级分类
  448. productTypeSn3: '' // 产品三级分类
  449. }
  450. this.productType = []
  451. this.$refs.table.refresh(true)
  452. },
  453. resetPurchaseForm () {
  454. this.productForm.productName = ''
  455. this.productForm.productCode = ''
  456. this.$refs.purchaseTable.refresh(true)
  457. },
  458. // 添加或修改
  459. handleAdd (row, type) {
  460. let params = {}
  461. if (type == 0 && !row.qty) {
  462. this.$message.warning('请输入数量后再添加!')
  463. return
  464. }
  465. // 添加
  466. if (type == 0) {
  467. params.productSn = row.productSn
  468. params.purchaseBillSn = this.detail.purchaseBillSn
  469. params.purchaseBillNo = this.detail.purchaseBillNo
  470. params.price = row.purchasePrice
  471. params.qty = row.qty
  472. } else { // 编辑
  473. // 清空成本价或数量时,值应保持未清空前的值,因成本价和数量都不可为空
  474. if (!row.qty) {
  475. row.qty = row.qtyBackups
  476. return
  477. }
  478. params = row
  479. }
  480. this.addLoading = true
  481. this.spinning = true
  482. purchaseDetailSave(params).then(res => {
  483. if (res.status == 200) {
  484. this.resetPurchaseDetail()
  485. this.$message.success(res.message)
  486. this.spinning = false
  487. } else {
  488. this.spinning = false
  489. }
  490. this.addLoading = false
  491. })
  492. },
  493. // 提交
  494. handleSubmit () {
  495. const _this = this
  496. this.subLoading = true
  497. this.spinning = true
  498. purchaseWriteSubmit({ id: this.detail.id }).then(res => {
  499. if (res.status == 200) {
  500. this.$message.success(res.message)
  501. setTimeout(() => {
  502. _this.handleBack()
  503. _this.spinning = false
  504. }, 1000)
  505. } else {
  506. _this.spinning = false
  507. }
  508. _this.subLoading = false
  509. })
  510. },
  511. // 导入产品
  512. hanldeOks () {
  513. this.$refs.purchaseTable.refresh(true)
  514. this.getOrderDetail()
  515. },
  516. // 上次缺货
  517. handleOutStock () {
  518. // 校验是否存在历史采购单,且上次采购存在缺货产品
  519. purchaseDetailCancelList({ pageNo: 1, pageSize: 5 }).then(res => {
  520. if (res.status == 200) {
  521. this.paramsData = {
  522. purchaseBillSn: this.$route.params.sn,
  523. purchaseBillNo: this.detail && this.detail.purchaseBillNo ? this.detail.purchaseBillNo : undefined
  524. }
  525. this.openOutStockModal = true
  526. }
  527. })
  528. },
  529. // 地址保存
  530. handleAddrOk (data) {
  531. const params = {
  532. purchaseBillSn: this.$route.params.sn,
  533. shippingAddressProvinceName: data.provinceName,
  534. shippingAddressCityName: data.cityName,
  535. shippingAddressCountyName: data.countyName,
  536. shippingAddress: data.addr,
  537. consigneeName: data.consigneeName,
  538. consigneeTel: data.consigneeTel
  539. }
  540. purchaseDetailAddress(params).then(res => {
  541. if (res.status == 200) {
  542. this.openAddrModal = false
  543. this.getOrderDetail()
  544. }
  545. })
  546. },
  547. // 查看产品
  548. handlePicDetail (row) {
  549. this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
  550. },
  551. // 上次缺货 导入成功
  552. hanldeOkOutStock () {
  553. this.$refs.purchaseTable.refresh(true)
  554. this.paramsData = null
  555. this.openOutStockModal = false
  556. },
  557. // 打印预览/快捷打印
  558. handlePrint (type, printerType) {
  559. const _this = this
  560. _this.spinning = true
  561. let url = purchaseDetailPrint
  562. let params = { sn: this.$route.params.sn, type: printerType }
  563. if (type == 'export') { // 导出
  564. url = purchaseDetailExport
  565. params = { sn: this.$route.params.sn }
  566. }
  567. // 打印或导出
  568. hdPrint(printerType, type, url, params, '采购单', function () {
  569. _this.spinning = false
  570. })
  571. },
  572. // 返回列表
  573. handleBack () {
  574. this.$router.push({ path: '/purchasingManagement/purchaseOrder/list' })
  575. },
  576. pageInit () {
  577. this.$nextTick(() => {
  578. this.getOrderDetail()
  579. this.resetPurchaseForm()
  580. this.resetSearchForm()
  581. this.$refs.searchProductCode.focus()
  582. })
  583. }
  584. },
  585. mounted () {
  586. this.showPage = true
  587. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  588. this.pageInit()
  589. }
  590. },
  591. activated () {
  592. this.showPage = true
  593. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  594. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  595. this.pageInit()
  596. }
  597. },
  598. deactivated () {
  599. // this.showPage = false
  600. },
  601. beforeRouteEnter (to, from, next) {
  602. next(vm => {})
  603. }
  604. }
  605. </script>
  606. <style lang="less">
  607. .purchaseOrderEdit-wrap{
  608. position: relative;
  609. height: 100%;
  610. padding-bottom: 51px;
  611. box-sizing: border-box;
  612. >.ant-spin-nested-loading{
  613. overflow-y: auto;
  614. height: 100%;
  615. }
  616. .noStock{
  617. text-decoration: line-through;
  618. color: red;
  619. }
  620. .billno{
  621. margin: 0 0 0 30px;
  622. font-size: 18px;
  623. font-weight: 600;
  624. display: inline-block;
  625. vertical-align: top;
  626. color: #666;
  627. }
  628. .purchaseOrderEdit-cont{
  629. margin-bottom: 10px;
  630. .sub-title{
  631. font-size: 12px;
  632. color: #808695;
  633. margin-left: 10px;
  634. }
  635. .tag-txt{
  636. font-size: 12px;
  637. color: #ed1c24;
  638. margin: 0 15px;
  639. }
  640. .edit-circle-btn{
  641. margin-left: 15px;
  642. i{
  643. vertical-align: text-bottom;
  644. }
  645. }
  646. .import-btn{
  647. margin-left: 15px;
  648. }
  649. }
  650. }
  651. </style>