salesReturnEdit.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. <template>
  2. <div class="salesReturnEdit-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="salesReturnEdit-back" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="salesReturnEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <span style="margin: 0 10px 0 20px;color: #666;font-size: 14px;font-weight: 600;">退货单号:{{ ordeDetail&&ordeDetail.salesReturnNo||'--' }}</span>
  9. <a-button id="salesReturnEdit-showDesc-btn" type="link" size="small" class="button-default" @click="isShowBisiceInfo=!isShowBisiceInfo">
  10. <a-icon :type="isShowBisiceInfo ? 'eye-invisible' : 'eye'"/> {{ isShowBisiceInfo?'隐藏':'查看' }}信息
  11. </a-button>
  12. <a-button
  13. id="salesReturnEdit-editInfo-btn"
  14. type="link"
  15. size="small"
  16. @click="handleEditCustom"
  17. class="button-info"
  18. key="0"> <a-icon type="edit"></a-icon> 编辑客户信息</a-button>
  19. </template>
  20. <!-- 操作区,位于 title 行的行尾 -->
  21. <template slot="extra" v-if="$hasPermissions('B_salesReturnPrint')">
  22. <Print :disabled="chooseLoadData.length==0" @handlePrint="handlePrint"></Print>
  23. </template>
  24. </a-page-header>
  25. <!-- 基础信息 -->
  26. <a-card size="small" :bordered="false" title="基础信息" v-show="isShowBisiceInfo" class="pages-wrap">
  27. <a-descriptions size="small" :column="3">
  28. <a-descriptions-item label="客户名称">{{ ordeDetail&&ordeDetail.buyerNameCurrent?ordeDetail.buyerName?ordeDetail.buyerName==ordeDetail.buyerNameCurrent?ordeDetail.buyerNameCurrent:ordeDetail.buyerNameCurrent+'('+ordeDetail.buyerName+')':ordeDetail.buyerNameCurrent:'--' }}</a-descriptions-item>
  29. <a-descriptions-item label="客户地址">
  30. <div v-if="ordeDetail&&(ordeDetail.provinceName || ordeDetail.cityName || ordeDetail.countyName || ordeDetail.customerAddr)">
  31. {{ ordeDetail&&ordeDetail.provinceName || '' }}
  32. {{ ordeDetail&&ordeDetail.cityName || '' }}
  33. {{ ordeDetail&&ordeDetail.countyName || '' }}
  34. {{ ordeDetail&&ordeDetail.customerAddr || '' }}
  35. </div>
  36. <span v-else>--</span>
  37. </a-descriptions-item>
  38. <a-descriptions-item label="联系电话">{{ ordeDetail&&ordeDetail.contactTel || '--' }}</a-descriptions-item>
  39. <a-descriptions-item label="退货单号">{{ ordeDetail&&ordeDetail.salesReturnNo || '--' }}</a-descriptions-item>
  40. <a-descriptions-item label="业务状态">{{ ordeDetail&&ordeDetail.stateDictValue || '--' }}</a-descriptions-item>
  41. <a-descriptions-item label="是否抓单">{{ ordeDetail&&ordeDetail.grabFlag==1?'抓单':'不抓单' }}</a-descriptions-item>
  42. <a-descriptions-item label="备注">{{ ordeDetail&&ordeDetail.remarks || '--' }}</a-descriptions-item>
  43. </a-descriptions>
  44. </a-card>
  45. <a-card size="small" :bordered="false" class="pages-wrap">
  46. <!-- 查询配件列表 -->
  47. <queryPart
  48. ref="queryPart"
  49. grabFlag="0"
  50. :newLoading="isInster"
  51. :warehouseCascadeData="warehouseCascadeData"
  52. @showCellChange="v=> showCell = v"
  53. @add="saveProduct"></queryPart>
  54. </a-card>
  55. <a-card size="small" :bordered="false" class="pages-wrap" ref="tableWrap">
  56. <!-- alert -->
  57. <a-alert style="margin-bottom: 10px;" type="info">
  58. <div slot="message" class="total-bar">
  59. <div v-if="countData">
  60. <span>退货总金额:{{ countData&&(countData.totalAmount || countData.totalAmount==0) ? toThousands(countData.totalAmount) : '--' }};</span>
  61. <span>总款数:{{ countData&&(countData.totalCategory || countData.totalCategory==0) ? countData.totalCategory : '--' }};</span>
  62. <span>总数量:{{ countData&&(countData.totalQty || countData.totalQty==0) ? countData.totalQty : '--' }};</span>
  63. <span>废品总数量:{{ countData&&(countData.totalCelQty || countData.totalCelQty==0) ? countData.totalCelQty : '--' }};</span>
  64. </div>
  65. <div v-if="ordeDetail">
  66. <div>
  67. 折扣金额:
  68. <a-input-number id="discount" v-model="ordeDetail.discountAmount" :min="0" :precision="2" :max="999999"/>
  69. <a-button id="salesReturnEdit-discount-btn" type="primary" @click="salesReturnDiscount" class="button-info">打折</a-button>
  70. </div>
  71. <div>
  72. 折扣:<strong>{{ ordeDetail&&(ordeDetail.discountRate || ordeDetail.discountRate==0) ? ordeDetail.discountRate+'%' : '--' }}</strong>;
  73. 折后总售价:<strong>{{ ordeDetail&&(ordeDetail.discountedAmount || ordeDetail.discountedAmount==0) ? toThousands(ordeDetail.discountedAmount) : '--' }}</strong>;
  74. </div>
  75. </div>
  76. </div>
  77. </a-alert>
  78. <!-- 搜索条件 -->
  79. <div class="table-page-search-wrapper">
  80. <a-row :gutter="15">
  81. <a-col :span="18">
  82. <a-form-model layout="inline" :model="productForm" @keyup.enter.native="$refs.table.refresh(true)">
  83. <a-row :gutter="15">
  84. <a-col :md="8" :sm="24">
  85. <a-form-model-item label="产品编码">
  86. <a-input id="salesReturnEdit-productCode" v-model.trim="productForm.productCode" allowClear placeholder="输入产品编码" />
  87. </a-form-model-item>
  88. </a-col>
  89. <a-col :md="8" :sm="24">
  90. <a-form-model-item label="产品名称">
  91. <a-input id="salesReturnEdit-productName" v-model.trim="productForm.productName" allowClear placeholder="输入产品名称" />
  92. </a-form-model-item>
  93. </a-col>
  94. <a-col :md="8" :sm="24">
  95. <a-form-model-item>
  96. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="salesReturn-refresh">查询</a-button>
  97. <a-button style="margin-left: 5px" @click="resetForm" id="salesReturn-reset">重置</a-button>
  98. </a-form-model-item>
  99. </a-col>
  100. </a-row>
  101. </a-form-model>
  102. </a-col>
  103. <a-col :span="6">
  104. <div style="float:right;overflow: hidden;">
  105. <!-- <a-button id="salesReturn-dru">导入明细</a-button> -->
  106. <a-button
  107. style="padding: 0 25px;"
  108. type="primary"
  109. :disabled="spinning"
  110. class="button-primary"
  111. @click="handleSubmit()"
  112. id="salesReturn-handleSubmit">提交</a-button>
  113. <a-button
  114. type="primary"
  115. ghost
  116. @click="salesReturnDelAll"
  117. :disabled="chooseLoadData.length==0"
  118. :loading="delLoading"
  119. style="margin-left: 10px"
  120. id="salesReturn-delAll">清空列表</a-button>
  121. </div>
  122. </a-col>
  123. </a-row>
  124. </div>
  125. <!-- 已选配件列表 -->
  126. <s-table
  127. class="sTable"
  128. ref="table"
  129. size="small"
  130. :rowKey="(record) => record.id"
  131. :columns="columns"
  132. :data="loadData"
  133. :defaultLoadData="false"
  134. :pageSize="10"
  135. :scroll="{ y: 200 }"
  136. bordered>
  137. <!-- 本次退货数量 -->
  138. <template slot="qty" slot-scope="text, record">
  139. <a-input-number
  140. :id="'salesReturn-qty-'+record.id"
  141. size="small"
  142. v-model="record.qty"
  143. :precision="0"
  144. :min="0"
  145. :max="999999"
  146. placeholder="请输入"
  147. @blur="e => onCellBlur(e.target.value, record, 'qty')"
  148. style="width: 100%;" />
  149. </template>
  150. <!-- 废品数量 -->
  151. <template slot="celQty" slot-scope="text, record">
  152. <a-input-number
  153. :id="'salesReturn-celQty-'+record.id"
  154. size="small"
  155. v-model="record.celQty"
  156. :precision="0"
  157. :min="0"
  158. :max="999999"
  159. placeholder="请输入"
  160. @blur="e => onCellBlur(e.target.value, record, 'celQty')"
  161. style="width: 100%;" />
  162. </template>
  163. <!-- 价格 -->
  164. <template slot="price" slot-scope="text, record">
  165. <a-input-number
  166. :id="'salesReturn-price-'+record.id"
  167. size="small"
  168. v-model="record.price"
  169. :precision="2"
  170. :min="0"
  171. :max="999999"
  172. placeholder="请输入"
  173. @blur="e => onCellBlur(e.target.value, record, 'price')"
  174. style="width: 100%;" />
  175. </template>
  176. <!-- 退货金额小计 -->
  177. <template slot="returnAmount" slot-scope="text, record">
  178. {{ toThousands(record.price * record.qty) }}
  179. </template>
  180. <!-- 仓库仓位 -->
  181. <template slot="warehouse" slot-scope="text, record, index">
  182. <a-cascader
  183. size="small"
  184. @change="e => changeWarehouseCascade(e, record, index)"
  185. v-model="record.warehouseCascade"
  186. expand-trigger="hover"
  187. :options="warehouseCascadeData"
  188. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  189. :id="'salesReturn-warehouseCascade-'+record.id"
  190. placeholder="请选择仓库仓位"
  191. style="width: 100%;" />
  192. </template>
  193. <!-- 操作 -->
  194. <template slot="action" slot-scope="text, record">
  195. <a-button
  196. size="small"
  197. type="link"
  198. :loading="delLoading"
  199. class="button-error"
  200. @click="handleDel(record)"
  201. :id="'salesReturn-del-'+record.id"
  202. >删除</a-button>
  203. </template>
  204. </s-table>
  205. </a-card>
  206. </a-spin>
  207. <!-- 选择客户弹框 -->
  208. <choose-custom-modal ref="editCustomModal" :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  209. </div>
  210. </template>
  211. <script>
  212. import { commonMixin } from '@/utils/mixin'
  213. import { STable, VSelect } from '@/components'
  214. import Print from '@/views/common/print.vue'
  215. import { hdPrint } from '@/libs/JGPrint'
  216. import queryPart from './queryPart.vue'
  217. import chooseCustomModal from './chooseCustomModal.vue'
  218. // 接口
  219. import { warehouseCascadeList } from '@/api/warehouse'
  220. import { getCurrentDealer } from '@/api/product'
  221. import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDiscount, salesReturnDelAll, salesReturnDetailDel, salesReturnSaveProduct, salesReturnSubmit, salesReturnDetailPrint, salesDetailExport } from '@/api/salesReturn'
  222. export default {
  223. name: 'SalesReturnEdit',
  224. components: {
  225. STable,
  226. VSelect,
  227. queryPart,
  228. chooseCustomModal,
  229. Print
  230. },
  231. mixins: [commonMixin],
  232. data () {
  233. return {
  234. spinning: false,
  235. disabled: false,
  236. orderId: null, // 单据id
  237. orderSn: null, // 单据sn
  238. buyerSn: null, // 客户sn
  239. openModal: false, // 选择客户弹框
  240. isInster: false, // 是否正在添加产品
  241. ordeDetail: { discountAmount: 0 }, // 单据详情信息
  242. delLoading: false, // 添加删除按钮loading
  243. warehouseCascadeData: [], // 仓库仓位
  244. // 已选产品
  245. dataSource: [],
  246. productForm: {
  247. productCode: '', // 产品编码
  248. productName: '', // 产品名称
  249. orderBy: 'sales_return_bill_detail.CREATE_DATE desc' // 排序
  250. },
  251. countData: null, // 统计信息
  252. chooseLoadData: [], // 已选列表原始数据
  253. // 加载数据方法 必须为 Promise 对象
  254. loadData: parameter => {
  255. this.disabled = true
  256. // 查询总计
  257. this.productForm.salesReturnBillSn = this.$route.params.sn
  258. this.getQueryCount(Object.assign(parameter, this.productForm))
  259. return salesReturnDetailList(Object.assign(parameter, this.productForm)).then(res => {
  260. let data
  261. if (res.status == 200) {
  262. data = res.data
  263. const no = (data.pageNo - 1) * data.pageSize
  264. for (var i = 0; i < data.list.length; i++) {
  265. data.list[i].no = no + i + 1
  266. data.list[i].qtyBackups = data.list[i].qty
  267. data.list[i].celQtyBackups = data.list[i].celQty
  268. data.list[i].priceBackups = data.list[i].price
  269. // 仓库仓位
  270. const warehouseSn = data.list[i].warehouseSn || undefined
  271. const warehouseLocationSn = data.list[i].warehouseLocationSn || undefined
  272. if (warehouseSn || warehouseLocationSn) {
  273. data.list[i].warehouseSnBackups = warehouseSn
  274. data.list[i].warehouseLocationSnBackups = warehouseLocationSn
  275. data.list[i].warehouseCascade = [warehouseSn, warehouseLocationSn]
  276. } else {
  277. data.list[i].warehouseCascade = undefined
  278. }
  279. }
  280. this.disabled = false
  281. this.chooseLoadData = data.list
  282. }
  283. return data
  284. })
  285. },
  286. printerType: 'NEEDLE', // 打印机类型
  287. isShowBisiceInfo: false, // 是否显示详情信息
  288. showCell: [], // 已选要显示的列
  289. currentDealerInfo: null
  290. }
  291. },
  292. computed: {
  293. columns () {
  294. const _this = this
  295. const arr = [
  296. { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
  297. { title: '产品编码', dataIndex: 'dealerProductEntity.code', align: 'center', width: '12%', customRender: function (text) { return text || '--' } },
  298. { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'left', width: '12%', customRender: function (text) { return text || '--' }, ellipsis: true },
  299. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', align: 'center', width: '12%', customRender: function (text) { return text || '--' } },
  300. { title: '售价', dataIndex: 'price', align: 'center', width: '7%', scopedSlots: { customRender: 'price' } },
  301. // { title: '批发价', dataIndex: 'wholesalePrice', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  302. // { title: '终端价', dataIndex: 'terminalPrice', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  303. { title: '单位', dataIndex: 'dealerProductEntity.unit', align: 'center', width: '5%', customRender: function (text) { return text || '--' } },
  304. { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: '12%', align: 'center' },
  305. { title: '退货数量', dataIndex: 'qty', align: 'center', width: '6%', scopedSlots: { customRender: 'qty' } },
  306. { title: '废品数量', dataIndex: 'celQty', align: 'center', width: '6%', scopedSlots: { customRender: 'celQty' } },
  307. { title: '退货金额小计', align: 'right', scopedSlots: { customRender: 'returnAmount' }, width: '8%' },
  308. { title: '折后金额小计', dataIndex: 'discountedAmount', align: 'right', width: '8%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  309. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  310. ]
  311. // 省级且有市级价权限
  312. if (_this.currentDealerInfo && _this.currentDealerInfo.dealerLevel == 'PROVINCE' && _this.$hasPermissions('M_ShowAllCityPrice')) {
  313. arr.splice(5, 0, { title: '批发价', dataIndex: 'wholesalePrice', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  314. arr.splice(6, 0, { title: '终端价', dataIndex: 'terminalPrice', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  315. } else {
  316. arr.splice(5, 0, { title: '终端价', dataIndex: 'terminalPrice', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  317. }
  318. return arr.filter(item => !_this.showCell.includes(item.dataIndex))
  319. }
  320. },
  321. methods: {
  322. // 返回列表
  323. handleBack () {
  324. this.$router.push({ name: 'salesReturnList' })
  325. },
  326. // 获取省级经销商、市级经销商和特约经销商信息
  327. getCurrentDealerInfo () {
  328. getCurrentDealer().then(res => {
  329. if (res.status == 200) {
  330. this.currentDealerInfo = res.data
  331. this.$refs.queryPart.setCell(this.currentDealerInfo)
  332. }
  333. })
  334. },
  335. // 选择客户成功
  336. chooseCustomOk (data) {
  337. this.openModal = false
  338. this.getOrderDetail()
  339. },
  340. // 编辑客户
  341. handleEditCustom () {
  342. this.openModal = true
  343. this.$refs.editCustomModal.editCust(this.ordeDetail)
  344. },
  345. // 已选产品,修改数量、价格、废品数量
  346. onCellBlur (val, record, type) {
  347. let valBackups
  348. if (type == 'qty') {
  349. valBackups = record.qtyBackups
  350. } else if (type == 'celQty') {
  351. valBackups = record.celQtyBackups
  352. } else if (type == 'price') {
  353. valBackups = record.priceBackups
  354. }
  355. // 光标移出,值发生改变再调用编辑接口
  356. if (val && val != valBackups) {
  357. // 废品数量不可大于本次退货数量
  358. if (Number(record.celQty) > Number(record.qty)) {
  359. this.$message.info('废品数量不可大于本次退货数量')
  360. this.reductionVal(record, type, valBackups)
  361. } else {
  362. this.saveProduct(record, 'edit')
  363. }
  364. } else {
  365. this.reductionVal(record, type, valBackups)
  366. }
  367. },
  368. // 恢复原值
  369. reductionVal (record, type, valBackups) {
  370. if (type == 'qty') {
  371. record.qty = valBackups
  372. } else if (type == 'celQty') {
  373. record.celQty = valBackups
  374. } else if (type == 'price') {
  375. record.price = valBackups
  376. }
  377. },
  378. // 仓库仓位 级联 列表
  379. getWarehouseCascade () {
  380. warehouseCascadeList({}).then(res => {
  381. if (res.status == 200) {
  382. res.data.map(item => {
  383. item.sn = item.warehouseSn
  384. if (item.warehouseLocationList) {
  385. item.warehouseLocationList.map(subItem => {
  386. subItem.sn = subItem.warehouseLocationSn
  387. })
  388. }
  389. })
  390. this.warehouseCascadeData = res.data
  391. } else {
  392. this.warehouseCascadeData = []
  393. }
  394. })
  395. },
  396. // 修改仓库仓位
  397. changeWarehouseCascade (val, opt, ind) {
  398. let loadData = this.chooseLoadData[ind]
  399. // 仓库无仓位
  400. if (val.length < 2) {
  401. this.$message.warning('当前仓库无仓位,请选择其他仓库')
  402. const warehouseSnBackups = loadData.warehouseSnBackups || undefined
  403. const warehouseLocationSnBackups = loadData.warehouseLocationSnBackups || undefined
  404. loadData.warehouseSn = warehouseSnBackups
  405. loadData.warehouseLocationSn = warehouseLocationSnBackups
  406. if (warehouseSnBackups || warehouseLocationSnBackups) {
  407. loadData.warehouseCascade = [warehouseSnBackups, warehouseLocationSnBackups]
  408. } else {
  409. loadData.warehouseCascade = undefined
  410. }
  411. } else {
  412. loadData.warehouseSn = val[0] ? val[0] : ''
  413. loadData.warehouseLocationSn = val[1] ? val[1] : ''
  414. loadData.warehouseSnBackups = val[0] ? val[0] : ''
  415. loadData.warehouseLocationSnBackups = val[1] ? val[1] : ''
  416. loadData = this.chooseLoadData[ind]
  417. this.saveProduct(loadData, 'edit')
  418. }
  419. },
  420. // 重置列表
  421. resetForm () {
  422. this.productForm = {
  423. productName: '',
  424. productCode: '',
  425. orderBy: 'sales_return_bill_detail.CREATE_DATE desc'
  426. }
  427. this.$refs.table.refresh(true)
  428. },
  429. // 明细统计
  430. getQueryCount (params) {
  431. salesReturnQueryCount(params).then(res => {
  432. this.countData = res.data || null
  433. })
  434. },
  435. // 获取单据详细
  436. getOrderDetail (flag) {
  437. salesReturnDetail({ sn: this.orderSn }).then(res => {
  438. this.ordeDetail = res.data || null
  439. if (!flag) {
  440. // 查询产品列表
  441. this.$refs.queryPart.pageInit(this.buyerSn, this.ordeDetail && this.ordeDetail.priceType || '')
  442. }
  443. })
  444. },
  445. // 打折
  446. salesReturnDiscount () {
  447. this.spinning = true
  448. salesReturnDiscount({
  449. discountAmount: this.ordeDetail.discountAmount || 0,
  450. salesReturnSn: this.ordeDetail.salesReturnSn,
  451. id: this.ordeDetail.id
  452. }).then(res => {
  453. if (res.status == 200) {
  454. // 获取详情,并刷新已选产品列表
  455. this.getOrderDetail(true)
  456. this.$refs.table.refresh(true)
  457. this.spinning = false
  458. } else {
  459. this.spinning = false
  460. }
  461. })
  462. },
  463. // 清空列表
  464. salesReturnDelAll () {
  465. const _this = this
  466. this.$confirm({
  467. title: '提示',
  468. content: '确认要清空已选产品列表吗?',
  469. centered: true,
  470. closable: true,
  471. onOk () {
  472. _this.delLoading = true
  473. _this.spinning = true
  474. salesReturnDelAll({ sn: _this.ordeDetail.salesReturnSn }).then(res => {
  475. if (res.status == 200) {
  476. _this.resetSearchForm()
  477. }
  478. _this.$message.info(res.message)
  479. _this.delLoading = false
  480. _this.spinning = false
  481. })
  482. }
  483. })
  484. },
  485. // 删除产品
  486. handleDel (row) {
  487. const _this = this
  488. this.$confirm({
  489. title: '提示',
  490. content: '确认要删除吗?',
  491. centered: true,
  492. closable: true,
  493. onOk () {
  494. _this.delLoading = true
  495. _this.spinning = true
  496. salesReturnDetailDel({ id: row.id }).then(res => {
  497. if (res.status == 200) {
  498. _this.resetSearchForm(true)
  499. }
  500. _this.$message.info(res.message)
  501. _this.delLoading = false
  502. _this.spinning = false
  503. })
  504. }
  505. })
  506. },
  507. // 重置
  508. resetSearchForm (flag) {
  509. this.$refs.table.refresh(!!flag)
  510. if (flag) {
  511. this.getOrderDetail(true)
  512. }
  513. },
  514. // 添加或修改产品
  515. saveProduct (row, type) {
  516. // 防止多次添加产品
  517. if (this.isInster) {
  518. return
  519. }
  520. this.isInster = true
  521. const params = {
  522. 'salesReturnBillSn': this.orderSn,
  523. 'salesReturnBillNo': this.ordeDetail.salesReturnNo,
  524. 'salesBillSn': row.salesBillSn,
  525. 'salesBillNo': row.salesBillNo,
  526. 'salesBillDetailSn': row.salesBillDetailSn,
  527. 'price': type == 'edit' ? row.price : row.salePrice,
  528. 'cost': row.putCost,
  529. 'productSn': row.productSn,
  530. 'priceLevel': row.priceLevel,
  531. 'celQty': row.celQty,
  532. 'hasReturnQty': row.returnQty,
  533. 'qty': row.returnQty,
  534. 'warehouseLocationSn': row.warehouseLocationSn,
  535. 'warehouseSn': row.warehouseSn
  536. }
  537. // 编辑
  538. if (type == 'edit') {
  539. params.id = row.id
  540. params.qty = row.qty
  541. } else {
  542. // 新增
  543. params.salesQty = row.qty
  544. }
  545. this.spinning = true
  546. salesReturnSaveProduct(params).then(res => {
  547. this.resetSearchForm(type == 'edit')
  548. if (type == 'new') {
  549. this.getOrderDetail(true)
  550. }
  551. this.isInster = false
  552. this.spinning = false
  553. })
  554. },
  555. // 提交销售单
  556. handleSubmit () {
  557. this.spinning = true
  558. salesReturnSubmit({ sn: this.orderSn }).then(res => {
  559. if (res.status == 200) {
  560. this.handleBack()
  561. this.$message.success(res.message)
  562. this.spinning = false
  563. } else {
  564. this.spinning = false
  565. }
  566. })
  567. },
  568. // 打印预览/快捷打印
  569. handlePrint (type, printerType) {
  570. const _this = this
  571. _this.spinning = true
  572. let url = salesReturnDetailPrint
  573. const params = { sn: this.$route.params.sn }
  574. if (type == 'export') { // 导出
  575. url = salesDetailExport
  576. }
  577. // 打印或导出
  578. hdPrint(printerType, type, url, params, '销售退货', function () {
  579. _this.spinning = false
  580. })
  581. },
  582. // 页面初始化
  583. pageInit () {
  584. this.orderId = this.$route.params.id
  585. this.orderSn = this.$route.params.sn
  586. this.buyerSn = this.$route.params.buyerSn
  587. this.getOrderDetail()
  588. this.getWarehouseCascade()
  589. this.resetForm()
  590. this.getCurrentDealerInfo()
  591. }
  592. },
  593. mounted () {
  594. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  595. this.pageInit()
  596. }
  597. },
  598. activated () {
  599. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  600. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  601. this.pageInit()
  602. }
  603. },
  604. beforeRouteEnter (to, from, next) {
  605. next(vm => {})
  606. }
  607. }
  608. </script>
  609. <style lang="less">
  610. .salesReturnEdit-wrap{
  611. position: relative;
  612. height: 100%;
  613. box-sizing: border-box;
  614. >.ant-spin-nested-loading{
  615. overflow-y: auto;
  616. height: 100%;
  617. }
  618. .pages-wrap{
  619. margin-top: 6px;
  620. .total-bar{
  621. display: flex;
  622. align-items: center;
  623. justify-content: space-between;
  624. > div{
  625. &:last-child{
  626. display: flex;
  627. align-items: center;
  628. justify-content: space-between;
  629. > div{
  630. padding: 0 10px;
  631. }
  632. }
  633. }
  634. }
  635. }
  636. }
  637. </style>