salesReturnGrabEdit.vue 26 KB

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