edit.vue 30 KB

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