edit.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  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="(systemFlag==0&&!isDealerUp)||(systemFlag==1&&!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. :paramsSn="$route.params.sn"
  285. :openModal="openOutStockModal"
  286. :orderType="detail&&detail.orderType"
  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. import { getParamValue } from '@/api/data'
  314. export default {
  315. name: 'PurchaseEdit',
  316. components: { STable, VSelect, ProductType, ProductBrand, ImportGuideModal, outStockModal, Print, chooseAddressModal, outStockListModal },
  317. mixins: [commonMixin],
  318. data () {
  319. return {
  320. isShowBisiceInfo: false, // 详细信息显示
  321. showPage: false, // 是否显示页面
  322. spinning: false,
  323. detail: null, // 详细信息
  324. subLoading: false, // 按钮loading
  325. defImg, // 默认图片
  326. // 选择产品
  327. addLoading: false, // 按钮loading
  328. productType: [], //
  329. queryParam: {
  330. productBrandSn: undefined, // 品牌
  331. code: '', // 产品编码
  332. name: '', // 产品名称
  333. origCode: '', // 原厂编码
  334. productTypeSn1: '', // 产品一级分类
  335. productTypeSn2: '', // 产品二级分类
  336. productTypeSn3: '', // 产品三级分类
  337. stockQty: ''// 可用库存小于等于
  338. },
  339. typeData: [], // 下拉数据
  340. advanced: false, // 高级搜索 展开/关闭
  341. disabled: false, // 查询、重置按钮是否可操作
  342. // 加载数据方法 必须为 Promise 对象
  343. loadData: parameter => {
  344. this.disabled = true
  345. return productListPurchase(Object.assign(parameter, this.queryParam, { purchaseBillSn: this.$route.params.sn })).then(res => {
  346. const data = res.data
  347. const no = (data.pageNo - 1) * data.pageSize
  348. for (var i = 0; i < data.list.length; i++) {
  349. data.list[i].no = no + i + 1
  350. data.list[i].qty = 1
  351. }
  352. this.disabled = false
  353. return data
  354. })
  355. },
  356. // -------已选产品-------------
  357. delLoading: false,
  358. productForm: {
  359. productName: '', // 产品名称
  360. productCode: '', // 产品编码
  361. orderBy: 'purchase_bill_detail.CREATE_DATE desc'
  362. },
  363. purchaseDisabled: false, // 查询、重置按钮是否可操作
  364. // 加载数据方法 必须为 Promise 对象
  365. chooseLoadData: parameter => {
  366. this.disabled = true
  367. // 查询总计
  368. const params = Object.assign({ pageNo: 1, pageSize: 5000 }, this.productForm, { purchaseBillSn: this.$route.params.sn })
  369. return purchaseDetailList(params).then(res => {
  370. const data = res.data
  371. const no = (data.pageNo - 1) * data.pageSize
  372. for (var i = 0; i < data.list.length; i++) {
  373. data.list[i].no = no + i + 1
  374. data.list[i].qtyBackups = data.list[i].qty
  375. }
  376. this.localDataSource = data.list
  377. this.disabled = false
  378. return data
  379. })
  380. },
  381. localDataSource: [], // 原始列表数据
  382. chooseData: [], // 已选列表数据
  383. openGuideModal: false, // 导入产品引导
  384. openOutStockModal: false, // 上次缺货弹框
  385. openAddrModal: false, // 选择地址弹框是否显示
  386. openOutStockListModal: false, // 导入缺货弹框
  387. systemFlag: null// 是否是转单产品
  388. }
  389. },
  390. computed: {
  391. // 是否上级
  392. isDealerUp () {
  393. return this.detail && (this.detail.purchaseTargetType == 'DEALER_UP' || this.detail.purchaseTargetType == 'DEALER_SUPPLIER')
  394. },
  395. // 列定义
  396. columns () {
  397. const _this = this
  398. const arr = [
  399. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  400. { title: '产品名称', dataIndex: 'name', width: '23%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  401. { title: '原厂编码', dataIndex: 'origCode', width: '14%', align: 'center', customRender: function (text) { return text && text != ' ' ? text : '--' } },
  402. { title: '单位', dataIndex: 'unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  403. { title: '包装数', scopedSlots: { customRender: 'baozh' }, width: '5%', align: 'center' },
  404. // { title: '成本价', dataIndex: 'purchasePrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  405. { title: '终端会员价', dataIndex: 'terminalPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  406. { title: '车主零售价', dataIndex: 'carOwnersPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  407. { title: '可用库存', dataIndex: 'currentStockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  408. { title: '采购数量', dataIndex: 'qty', scopedSlots: { customRender: 'storageQuantity' }, width: '6%', align: 'center' },
  409. { title: '产品图片', scopedSlots: { customRender: 'imageUrl' }, width: '6%', align: 'center' },
  410. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  411. ]
  412. // 产品来源,如果是上级经销商
  413. if (this.isDealerUp) {
  414. arr.splice(1, 0, { title: '产品编码', scopedSlots: { customRender: 'code' }, width: '15%', align: 'center', sorter: true })
  415. arr.splice(2, 0, { title: '产品来源', dataIndex: 'sysFlagDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } })
  416. } else {
  417. // 不是上级
  418. arr.splice(1, 0, { title: '产品编码', dataIndex: 'code', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true })
  419. }
  420. // 成本价权限
  421. if (this.$hasPermissions('M_ShowAllCost')) {
  422. 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) : '--') } })
  423. }
  424. return arr
  425. },
  426. // 已添加列表列
  427. chooseColumns () {
  428. const _this = this
  429. const arr = [
  430. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  431. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '15%', align: 'center' },
  432. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '24%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  433. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  434. { title: '采购数量', scopedSlots: { customRender: 'storageQuantity' }, width: '8%', align: 'center' },
  435. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  436. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  437. ]
  438. // 成本价权限
  439. if (this.$hasPermissions('M_ShowAllCost')) {
  440. arr.splice(4, 0, { title: '采购单价', dataIndex: 'discountedPrice', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  441. arr.splice(7, 0, { title: '采购金额', dataIndex: 'discountedAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  442. }
  443. return arr
  444. }
  445. },
  446. methods: {
  447. // 获取采购单基本信息
  448. getOrderDetail () {
  449. purchaseDetailBySn({ sn: this.$route.params.sn }).then(res => {
  450. if (res.status == 200) {
  451. this.detail = res.data
  452. }
  453. })
  454. },
  455. // 删除产品
  456. handleDel (row) {
  457. const _this = this
  458. this.$confirm({
  459. title: '提示',
  460. content: '确认要删除吗?',
  461. centered: true,
  462. closable: true,
  463. onOk () {
  464. _this.delLoading = true
  465. _this.spinning = true
  466. purchaseDetailDel({ id: row.id }).then(res => {
  467. if (res.status == 200) {
  468. _this.resetPurchaseDetail(true)
  469. _this.$message.success(res.message)
  470. _this.delLoading = false
  471. _this.spinning = false
  472. } else {
  473. _this.delLoading = false
  474. _this.spinning = false
  475. }
  476. })
  477. }
  478. })
  479. },
  480. // 重新查询已选产品
  481. resetPurchaseDetail (flag) {
  482. this.$refs.purchaseTable.refresh(!!flag)
  483. this.getOrderDetail()
  484. },
  485. // 修改数量后
  486. qtyBlur (val, record) {
  487. // 光标移出,值发生改变再调用编辑接口
  488. if (val != record.qtyBackups) {
  489. this.handleAdd(record, 1)
  490. }
  491. },
  492. // 产品分类 change
  493. changeProductType (val, opt) {
  494. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  495. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  496. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  497. },
  498. // 重置产品库
  499. resetSearchForm () {
  500. this.queryParam = {
  501. productBrandSn: undefined,
  502. code: '', // 产品编码
  503. name: '', // 产品名称
  504. origCode: '', // 原厂编码
  505. productTypeSn1: '', // 产品一级分类
  506. productTypeSn2: '', // 产品二级分类
  507. productTypeSn3: '', // 产品三级分类
  508. stockQty: ''// 可用库存小于等于
  509. }
  510. this.productType = []
  511. this.$refs.table.refresh(true)
  512. },
  513. // 已选产品列表重置
  514. resetPurchaseForm () {
  515. this.productForm.productName = ''
  516. this.productForm.productCode = ''
  517. this.$refs.purchaseTable.refresh(true)
  518. },
  519. // 添加或修改
  520. handleAdd (row, type) {
  521. let params = {}
  522. if (type == 0 && !row.qty) {
  523. this.$message.warning('请输入数量后再添加!')
  524. return
  525. }
  526. // 添加操作
  527. if (type == 0) {
  528. // 如果是上级
  529. if (this.isDealerUp) {
  530. // 如果有价格
  531. if (row.purchasePrice) {
  532. params.productSn = row.productSn
  533. params.purchaseBillSn = this.detail.purchaseBillSn
  534. params.purchaseBillNo = this.detail.purchaseBillNo
  535. params.price = row.purchasePrice
  536. params.qty = row.qty
  537. params.priceLevel = row.priceLevel
  538. } else {
  539. this.$message.warning('成本价不能为空!(注:请联系【供应商】完善定价)')
  540. return
  541. }
  542. } else {
  543. // 不是上级,且有成本价、终端会员价、车主零售价
  544. if (row.purchasePrice && row.terminalPrice && row.carOwnersPrice) {
  545. params.productSn = row.productSn
  546. params.purchaseBillSn = this.detail.purchaseBillSn
  547. params.purchaseBillNo = this.detail.purchaseBillNo
  548. params.price = row.purchasePrice
  549. params.qty = row.qty
  550. params.priceLevel = row.priceLevel
  551. } else {
  552. this.$message.warning('成本价、终端会员价、车主零售价不能为空!(注:请联系【供应商】完善定价)')
  553. return
  554. }
  555. }
  556. } else {
  557. // 编辑操作
  558. // 清空成本价或数量时,值应保持未清空前的值,因成本价和数量都不可为空
  559. if (!row.qty) {
  560. row.qty = row.qtyBackups
  561. return
  562. }
  563. params = row
  564. }
  565. this.addLoading = true
  566. this.spinning = true
  567. // 保存数据
  568. purchaseDetailSave(params).then(res => {
  569. if (res.status == 200) {
  570. this.resetPurchaseDetail()
  571. this.$message.success(res.message)
  572. this.spinning = false
  573. } else {
  574. this.spinning = false
  575. }
  576. this.addLoading = false
  577. })
  578. },
  579. // 提交单据
  580. handleSubmit () {
  581. const _this = this
  582. this.subLoading = true
  583. this.spinning = true
  584. purchaseWriteSubmit({ id: this.detail.id }).then(res => {
  585. if (res.status == 200) {
  586. if (res.data && res.data.length > 0) {
  587. const resTips = res.data.join('、')
  588. this.$confirm({
  589. title: '提示',
  590. content: resTips + '暂不销售,请删除后重新提交采购单',
  591. centered: true,
  592. okText: '知道了',
  593. cancelText: '取消', // 将cancelText设置为空字符串或去掉该属性可以隐藏取消按钮
  594. cancelButtonProps: {
  595. style: {
  596. display: 'none' // 通过设置样式隐藏取消按钮
  597. }
  598. },
  599. onOk () {
  600. console.log('知道了')
  601. }
  602. })
  603. } else {
  604. this.$message.success(res.message)
  605. setTimeout(() => {
  606. _this.handleBack()
  607. _this.spinning = false
  608. }, 1000)
  609. }
  610. }
  611. _this.spinning = false
  612. _this.subLoading = false
  613. })
  614. },
  615. // 导入产品
  616. hanldeOks () {
  617. this.$refs.purchaseTable.refresh(true)
  618. this.getOrderDetail()
  619. },
  620. // 导入缺货
  621. handleOutStock () {
  622. this.openOutStockListModal = true
  623. const _this = this
  624. _this.$nextTick(() => {
  625. _this.$refs.outStockList.resetSearchForm()
  626. })
  627. },
  628. // 导入缺货成功
  629. hanldeOkOutStockList (con) {
  630. const _this = this
  631. _this.openOutStockModal = true
  632. _this.chooseData = con
  633. _this.$nextTick(() => {
  634. _this.$refs.outStock.resetSearchForm()
  635. })
  636. },
  637. // 地址保存
  638. handleAddrOk (data) {
  639. const params = {
  640. purchaseBillSn: this.$route.params.sn,
  641. shippingAddressProvinceName: data.provinceName,
  642. shippingAddressCityName: data.cityName,
  643. shippingAddressCountyName: data.countyName,
  644. shippingAddress: data.addr,
  645. consigneeName: data.consigneeName,
  646. consigneeTel: data.consigneeTel
  647. }
  648. purchaseDetailAddress(params).then(res => {
  649. if (res.status == 200) {
  650. this.openAddrModal = false
  651. this.getOrderDetail()
  652. }
  653. })
  654. },
  655. // 查看产品
  656. handlePicDetail (row) {
  657. this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
  658. },
  659. // 导入缺货 导入成功
  660. hanldeOkOutStock () {
  661. this.$refs.purchaseTable.refresh(true)
  662. this.chooseData = null
  663. this.openOutStockModal = false
  664. this.openOutStockListModal = false
  665. },
  666. // 打印预览/快捷打印
  667. handlePrint (type, printerType) {
  668. const _this = this
  669. _this.spinning = true
  670. let url = purchaseDetailPrint
  671. let params = { sn: this.$route.params.sn, type: printerType }
  672. if (type == 'export') { // 导出
  673. url = purchaseDetailExport
  674. params = { sn: this.$route.params.sn }
  675. }
  676. // 打印或导出
  677. hdPrint(printerType, type, url, params, '采购单', function () {
  678. _this.spinning = false
  679. })
  680. },
  681. // 获取系统参数 判断是否显示产品类型
  682. getSystemInfo () {
  683. getParamValue({ code: 'TIRE_OPEN' }).then(res => {
  684. if (res.status == 200) {
  685. this.systemFlag = res.data
  686. }
  687. })
  688. },
  689. // 返回列表
  690. handleBack () {
  691. this.$router.push({ path: '/purchasingManagement/purchaseOrder/list' })
  692. },
  693. // 页面初始化
  694. pageInit () {
  695. this.$nextTick(() => {
  696. this.getOrderDetail()
  697. this.resetPurchaseForm()
  698. this.resetSearchForm()
  699. this.$refs.searchProductCode.focus()
  700. })
  701. this.getSystemInfo()
  702. }
  703. },
  704. mounted () {
  705. this.showPage = true
  706. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  707. this.pageInit()
  708. }
  709. },
  710. activated () {
  711. this.showPage = true
  712. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  713. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  714. this.pageInit()
  715. }
  716. },
  717. beforeRouteEnter (to, from, next) {
  718. next(vm => {})
  719. }
  720. }
  721. </script>
  722. <style lang="less">
  723. .purchaseOrderEdit-wrap{
  724. position: relative;
  725. height: 100%;
  726. padding-bottom: 70px;
  727. box-sizing: border-box;
  728. >.ant-spin-nested-loading{
  729. overflow-y: auto;
  730. height: 100%;
  731. }
  732. .noStock{
  733. text-decoration: line-through;
  734. color: red;
  735. }
  736. .billno{
  737. margin: 0 0 0 30px;
  738. font-size: 18px;
  739. font-weight: 600;
  740. display: inline-block;
  741. vertical-align: middle;
  742. color: #666;
  743. }
  744. .purchaseOrderEdit-cont{
  745. margin-bottom: 10px;
  746. .sub-title{
  747. font-size: 12px;
  748. color: #808695;
  749. margin-left: 10px;
  750. }
  751. .tag-txt{
  752. font-size: 12px;
  753. color: #ed1c24;
  754. margin: 0 15px;
  755. }
  756. .edit-circle-btn{
  757. margin-left: 15px;
  758. i{
  759. vertical-align: text-bottom;
  760. }
  761. }
  762. .import-btn{
  763. margin-left: 15px;
  764. }
  765. }
  766. .gutter-row:nth-child(1),.gutter-row:nth-child(2){
  767. margin-bottom:10px;
  768. }
  769. .ant-collapse .ant-collapse-item-disabled > .ant-collapse-header{
  770. color:#333;
  771. }
  772. }
  773. </style>