edit.vue 29 KB

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