edit.vue 29 KB

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