edit.vue 32 KB

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