edit.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  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. 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. </div>
  168. <!-- 已选产品 -->
  169. <div 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 type="primary" class="button-primary" id="purchaseOrderEdit-import-btn" @click="handleOutStock">上次缺货</a-button>
  209. <a-button 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. </div>
  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 '@/views/common/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. delLoading: false,
  330. productForm: {
  331. productName: '',
  332. productCode: '',
  333. orderBy: 'purchase_bill_detail.CREATE_DATE desc'
  334. },
  335. purchaseDisabled: false, // 查询、重置按钮是否可操作
  336. // 加载数据方法 必须为 Promise 对象
  337. chooseLoadData: parameter => {
  338. this.disabled = true
  339. // 查询总计
  340. const params = Object.assign({ pageNo: 1, pageSize: 5000 }, this.productForm, { purchaseBillSn: this.$route.params.sn })
  341. return purchaseDetailList(params).then(res => {
  342. const data = res.data
  343. const no = (data.pageNo - 1) * data.pageSize
  344. for (var i = 0; i < data.list.length; i++) {
  345. data.list[i].no = no + i + 1
  346. data.list[i].qtyBackups = data.list[i].qty
  347. }
  348. this.localDataSource = data.list
  349. this.disabled = false
  350. return data
  351. })
  352. },
  353. localDataSource: [],
  354. openGuideModal: false, // 导入产品引导
  355. openOutStockModal: false,
  356. paramsData: null,
  357. openAddrModal: false // 选择地址弹框是否显示
  358. }
  359. },
  360. computed: {
  361. isDealerUp () {
  362. return this.detail && this.detail.purchaseTargetType == 'DEALER_UP'
  363. },
  364. columns () {
  365. const _this = this
  366. const arr = [
  367. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  368. { title: '产品名称', dataIndex: 'name', width: '23%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  369. { title: '原厂编码', dataIndex: 'origCode', width: '14%', align: 'center', customRender: function (text) { return text && text != ' ' ? text : '--' } },
  370. { title: '单位', dataIndex: 'unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  371. { title: '包装数', scopedSlots: { customRender: 'baozh' }, width: '5%', align: 'center' },
  372. // { title: '成本价', dataIndex: 'purchasePrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  373. { title: '终端会员价', dataIndex: 'terminalPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  374. { title: '车主零售价', dataIndex: 'carOwnersPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  375. { title: '采购数量', dataIndex: 'qty', scopedSlots: { customRender: 'storageQuantity' }, width: '6%', align: 'center' },
  376. { title: '产品图片', scopedSlots: { customRender: 'imageUrl' }, width: '6%', align: 'center' },
  377. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  378. ]
  379. // 产品来源
  380. if (this.isDealerUp) {
  381. arr.splice(1,0,{ title: '产品编码', scopedSlots: { customRender: 'code' }, width: '15%', align: 'center', sorter: true })
  382. arr.splice(6, 0, { title: '产品来源', dataIndex: 'sysFlagDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } })
  383. }else{
  384. arr.splice(1,0,{ title: '产品编码', dataIndex: 'code', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true })
  385. }
  386. if (this.$hasPermissions('M_ShowAllCost')) {
  387. 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) : '--') } })
  388. }
  389. return arr
  390. },
  391. chooseColumns () {
  392. const _this = this
  393. const arr = [
  394. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  395. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '20%', align: 'center' },
  396. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  397. // { title: '采购单价', dataIndex: 'discountedPrice', width: '20%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  398. { title: '采购数量', scopedSlots: { customRender: 'storageQuantity' }, width: '10%', align: 'center' },
  399. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  400. // { title: '采购金额', dataIndex: 'discountedAmount', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  401. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  402. ]
  403. if (this.$hasPermissions('M_ShowAllCost')) {
  404. arr.splice(3, 0, { title: '采购单价', dataIndex: 'discountedPrice', width: '20%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  405. arr.splice(6, 0, { title: '采购金额', dataIndex: 'discountedAmount', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  406. }
  407. return arr
  408. }
  409. },
  410. methods: {
  411. // 获取采购单基本信息
  412. getOrderDetail () {
  413. purchaseDetailBySn({ sn: this.$route.params.sn }).then(res => {
  414. if (res.status == 200) {
  415. this.detail = res.data
  416. }
  417. })
  418. },
  419. // 删除产品
  420. handleDel (row) {
  421. const _this = this
  422. this.$confirm({
  423. title: '提示',
  424. content: '确认要删除吗?',
  425. centered: true,
  426. closable: true,
  427. onOk () {
  428. _this.delLoading = true
  429. _this.spinning = true
  430. purchaseDetailDel({ id: row.id }).then(res => {
  431. if (res.status == 200) {
  432. _this.resetPurchaseDetail(true)
  433. _this.$message.success(res.message)
  434. _this.delLoading = false
  435. _this.spinning = false
  436. } else {
  437. _this.delLoading = false
  438. _this.spinning = false
  439. }
  440. })
  441. }
  442. })
  443. },
  444. // 重新查询已选产品
  445. resetPurchaseDetail (flag) {
  446. this.$refs.purchaseTable.refresh(!!flag)
  447. this.getOrderDetail()
  448. },
  449. // 修改数量后
  450. qtyBlur (val, record) {
  451. // 光标移出,值发生改变再调用编辑接口
  452. if (val != record.qtyBackups) {
  453. this.handleAdd(record, 1)
  454. }
  455. },
  456. filterOption (input, option) {
  457. return (
  458. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  459. )
  460. },
  461. // 产品分类 change
  462. changeProductType (val, opt) {
  463. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  464. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  465. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  466. },
  467. // 重置产品库
  468. resetSearchForm () {
  469. this.queryParam = {
  470. productBrandSn: undefined,
  471. code: '', // 产品编码
  472. name: '', // 产品名称
  473. origCode: '', // 原厂编码
  474. productTypeSn1: '', // 产品一级分类
  475. productTypeSn2: '', // 产品二级分类
  476. productTypeSn3: '' // 产品三级分类
  477. }
  478. this.productType = []
  479. this.$refs.table.refresh(true)
  480. },
  481. resetPurchaseForm () {
  482. this.productForm.productName = ''
  483. this.productForm.productCode = ''
  484. this.$refs.purchaseTable.refresh(true)
  485. },
  486. // 添加或修改
  487. handleAdd (row, type) {
  488. let params = {}
  489. if (type == 0 && !row.qty) {
  490. this.$message.warning('请输入数量后再添加!')
  491. return
  492. }
  493. // 添加
  494. if (type == 0) {
  495. params.productSn = row.productSn
  496. params.purchaseBillSn = this.detail.purchaseBillSn
  497. params.purchaseBillNo = this.detail.purchaseBillNo
  498. params.price = row.purchasePrice
  499. params.qty = row.qty
  500. } else { // 编辑
  501. // 清空成本价或数量时,值应保持未清空前的值,因成本价和数量都不可为空
  502. if (!row.qty) {
  503. row.qty = row.qtyBackups
  504. return
  505. }
  506. params = row
  507. }
  508. this.addLoading = true
  509. this.spinning = true
  510. purchaseDetailSave(params).then(res => {
  511. if (res.status == 200) {
  512. this.resetPurchaseDetail()
  513. this.$message.success(res.message)
  514. this.spinning = false
  515. } else {
  516. this.spinning = false
  517. }
  518. this.addLoading = false
  519. })
  520. },
  521. // 提交
  522. handleSubmit () {
  523. const _this = this
  524. this.subLoading = true
  525. this.spinning = true
  526. purchaseWriteSubmit({ id: this.detail.id }).then(res => {
  527. if (res.status == 200) {
  528. this.$message.success(res.message)
  529. setTimeout(() => {
  530. _this.handleBack()
  531. _this.spinning = false
  532. }, 1000)
  533. } else {
  534. _this.spinning = false
  535. }
  536. _this.subLoading = false
  537. })
  538. },
  539. // 导入产品
  540. hanldeOks () {
  541. this.$refs.purchaseTable.refresh(true)
  542. this.getOrderDetail()
  543. },
  544. // 上次缺货
  545. handleOutStock () {
  546. // 校验是否存在历史采购单,且上次采购存在缺货产品
  547. purchaseDetailCancelList({ pageNo: 1, pageSize: 5 }).then(res => {
  548. if (res.status == 200) {
  549. this.paramsData = {
  550. purchaseBillSn: this.$route.params.sn,
  551. purchaseBillNo: this.detail && this.detail.purchaseBillNo ? this.detail.purchaseBillNo : undefined
  552. }
  553. this.openOutStockModal = true
  554. }
  555. })
  556. },
  557. // 地址保存
  558. handleAddrOk (data) {
  559. const params = {
  560. purchaseBillSn: this.$route.params.sn,
  561. shippingAddressProvinceName: data.provinceName,
  562. shippingAddressCityName: data.cityName,
  563. shippingAddressCountyName: data.countyName,
  564. shippingAddress: data.addr,
  565. consigneeName: data.consigneeName,
  566. consigneeTel: data.consigneeTel
  567. }
  568. purchaseDetailAddress(params).then(res => {
  569. if (res.status == 200) {
  570. this.openAddrModal = false
  571. this.getOrderDetail()
  572. }
  573. })
  574. },
  575. // 查看产品
  576. handlePicDetail (row) {
  577. this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
  578. },
  579. // 上次缺货 导入成功
  580. hanldeOkOutStock () {
  581. this.$refs.purchaseTable.refresh(true)
  582. this.paramsData = null
  583. this.openOutStockModal = false
  584. },
  585. // 打印预览/快捷打印
  586. handlePrint (type, printerType) {
  587. const _this = this
  588. _this.spinning = true
  589. let url = purchaseDetailPrint
  590. let params = { sn: this.$route.params.sn, type: printerType }
  591. if (type == 'export') { // 导出
  592. url = purchaseDetailExport
  593. params = { sn: this.$route.params.sn }
  594. }
  595. // 打印或导出
  596. hdPrint(printerType, type, url, params, '采购单', function () {
  597. _this.spinning = false
  598. })
  599. },
  600. // 返回列表
  601. handleBack () {
  602. this.$router.push({ path: '/purchasingManagement/purchaseOrder/list' })
  603. },
  604. pageInit () {
  605. this.$nextTick(() => {
  606. this.getOrderDetail()
  607. this.resetPurchaseForm()
  608. this.resetSearchForm()
  609. this.$refs.searchProductCode.focus()
  610. })
  611. }
  612. },
  613. mounted () {
  614. this.showPage = true
  615. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  616. this.pageInit()
  617. }
  618. },
  619. activated () {
  620. this.showPage = true
  621. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  622. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  623. this.pageInit()
  624. }
  625. },
  626. deactivated () {
  627. // this.showPage = false
  628. },
  629. beforeRouteEnter (to, from, next) {
  630. next(vm => {})
  631. }
  632. }
  633. </script>
  634. <style lang="less">
  635. .purchaseOrderEdit-wrap{
  636. position: relative;
  637. height: 100%;
  638. padding-bottom: 51px;
  639. box-sizing: border-box;
  640. >.ant-spin-nested-loading{
  641. overflow-y: auto;
  642. height: 100%;
  643. }
  644. .noStock{
  645. text-decoration: line-through;
  646. color: red;
  647. }
  648. .billno{
  649. margin: 0 0 0 30px;
  650. font-size: 18px;
  651. font-weight: 600;
  652. display: inline-block;
  653. vertical-align: middle;
  654. color: #666;
  655. }
  656. .purchaseOrderEdit-cont{
  657. margin-bottom: 10px;
  658. .sub-title{
  659. font-size: 12px;
  660. color: #808695;
  661. margin-left: 10px;
  662. }
  663. .tag-txt{
  664. font-size: 12px;
  665. color: #ed1c24;
  666. margin: 0 15px;
  667. }
  668. .edit-circle-btn{
  669. margin-left: 15px;
  670. i{
  671. vertical-align: text-bottom;
  672. }
  673. }
  674. .import-btn{
  675. margin-left: 15px;
  676. }
  677. }
  678. .gutter-row:nth-child(1),.gutter-row:nth-child(2){
  679. margin-bottom:10px;
  680. }
  681. .ant-collapse .ant-collapse-item-disabled > .ant-collapse-header{
  682. color:#333;
  683. }
  684. }
  685. </style>