edit.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <div class="transferReturnEdit-wrap">
  3. <!-- <a-spin :spinning="spinning" tip="Loading..."> -->
  4. <div class="ant-spin-nested-loading">
  5. <a-page-header :ghost="false" :backIcon="false" class="transferReturnEdit-back" >
  6. <!-- 自定义的二级文字标题 -->
  7. <template slot="subTitle">
  8. <a id="transferReturnEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  9. <span style="margin: 0 15px;color: #666;font-weight: bold;">单号:{{ basicInfoData&&basicInfoData.allocateReturnNo }}</span>
  10. <a-button id="transferReturnEdit-showDetail" type="link" class="button-default" @click="showDetail=!showDetail">
  11. <a-icon :type="showDetail ? 'eye-invisible' : 'eye'"/> {{ showDetail?'隐藏':'查看' }}信息
  12. </a-button>
  13. </template>
  14. <!-- 操作区,位于 title 行的行尾 -->
  15. <template slot="extra">
  16. <print :params="{allocateReturnSn: allocateReturnSn}" :basicInfoData="basicInfoData" :disabled="localDataSource.length==0" @loading="spinning=true" @unloading="spinning=false"></print>
  17. </template>
  18. </a-page-header>
  19. <a-card size="small" :bordered="false" v-if="basicInfoData" class="transferReturnEdit-cont" v-show="showDetail">
  20. <a-descriptions :column="3">
  21. <a-descriptions-item label="调拨退货单号">{{ (basicInfoData&&basicInfoData.allocateReturnNo) || '--' }}</a-descriptions-item>
  22. <a-descriptions-item label="调拨退货对象">{{ (basicInfoData&&basicInfoData.targetTypeDictValue) || '--' }}</a-descriptions-item>
  23. <a-descriptions-item label="调拨退货对象名称">{{ (basicInfoData&&basicInfoData.targetName) || '--' }}</a-descriptions-item>
  24. <a-descriptions-item label="调入仓库">
  25. <!-- <warehouse
  26. style="width:200px;"
  27. :allowClear="false"
  28. v-model="basicInfoData.warehouseSn"
  29. @change="updateWarehouse"
  30. id="basicInfo-warehouseSn"
  31. placeholder="请选择调入仓库"
  32. /> -->
  33. {{ (basicInfoData&&basicInfoData.warehouseName) || '--' }}
  34. </a-descriptions-item>
  35. <a-descriptions-item label="费用/调拨退货类型">
  36. <AllocateType
  37. id="transferReturnEdit-allocateTypeVal"
  38. style="width: 220px;"
  39. v-model="allocateTypeVal"
  40. :allowClear="false"
  41. placeholder="请选择费用/调拨退货类型"
  42. @change="changeAllocateType"></AllocateType>
  43. </a-descriptions-item>
  44. <a-descriptions-item label="是否抓单">{{ (basicInfoData&&basicInfoData.grabFlagDictValue) || '--' }}</a-descriptions-item>
  45. <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
  46. <a-descriptions-item label="备注">
  47. {{ (basicInfoData&&basicInfoData.remarks) }}
  48. <a-icon type="form" title="编辑备注" @click="editRemark = true" style="color: dodgerblue;font-size: 14px;" />
  49. </a-descriptions-item>
  50. </a-descriptions>
  51. </a-card>
  52. <!-- 选择产品 -->
  53. <a-card size="small" title="选择产品" :bordered="false" class="transferReturnEdit-cont">
  54. <!-- 筛选条件 -->
  55. <div class="table-page-search-wrapper">
  56. <a-form layout="inline" id="transferReturnEdit-form" @keyup.enter.native="$refs.table.refresh(true)">
  57. <a-row :gutter="15">
  58. <a-col :md="6" :sm="24">
  59. <a-form-item label="产品编码" prop="productCode">
  60. <a-input id="transferReturnEdit-productCode" v-model.trim="queryParam.productCode" placeholder="请输入产品编码" allowClear />
  61. </a-form-item>
  62. </a-col>
  63. <a-col :md="6" :sm="24">
  64. <a-form-item label="产品名称" prop="productName">
  65. <a-input id="transferReturnEdit-productName" v-model.trim="queryParam.productName" placeholder="请输入产品名称" allowClear />
  66. </a-form-item>
  67. </a-col>
  68. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  69. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="transferReturnEdit-refresh">查询</a-button>
  70. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="transferReturnEdit-reset">重置</a-button>
  71. </a-col>
  72. </a-row>
  73. </a-form>
  74. </div>
  75. <!-- 列表 -->
  76. <s-table
  77. class="sTable"
  78. ref="table"
  79. size="small"
  80. index="0"
  81. tableId="table1"
  82. :rowKey="(record) => record.stockSn"
  83. rowKeyName="stockSn"
  84. :columns="columns"
  85. :customRow="handleClickRow"
  86. :data="loadData"
  87. :scroll="{ y: 300 }"
  88. :defaultLoadData="false"
  89. bordered>
  90. <!-- 价格级别 -->
  91. <template slot="priceLevel" slot-scope="text, record, index">
  92. <span v-if="record.powerFlag!=0">{{ record.priceLevelDictValue }}</span>
  93. <v-select
  94. v-else
  95. style="width:90%;"
  96. size="small"
  97. code="PRICE_LEVEL"
  98. v-model="record.priceLevel"
  99. allowClear
  100. placeholder="请选择价格级别"
  101. :id="'transferReturnEdit-priceLevel'+record.stockSn"
  102. @change="e => handlePriceLevel(e,index)"></v-select>
  103. </template>
  104. <!-- 退货单价 -->
  105. <template slot="returnPrice" slot-scope="text, record">
  106. <span>{{ record.productPrice }}</span>
  107. </template>
  108. <!-- 退货数量 -->
  109. <template slot="returnQty" slot-scope="text, record">
  110. <div @dblclick.stop>
  111. <a-input-number
  112. size="small"
  113. v-model="record.qty"
  114. :precision="0"
  115. :min="1"
  116. :max="99999999"
  117. placeholder="请输入"
  118. :id="'transferReturnEdit-qty'+record.stockSn"
  119. style="width: 100%;" />
  120. </div>
  121. </template>
  122. <!-- 操作 -->
  123. <template slot="action" slot-scope="text, record">
  124. <a-button
  125. size="small"
  126. type="link"
  127. class="button-primary"
  128. @click="handleAdd(record)"
  129. :id="'transferReturnEdit-add-btn'+record.stockSn">添加</a-button>
  130. </template>
  131. </s-table>
  132. </a-card>
  133. <!-- 已选产品 -->
  134. <a-card size="small" title="已选产品" :bordered="false" class="transferReturnEdit-cont">
  135. <!-- 总计 -->
  136. <a-alert type="info" style="margin-bottom:10px">
  137. <div slot="message">
  138. 退货总数量:<strong>{{ (basicInfoData&&(basicInfoData.totalQty || basicInfoData.totalQty==0)) ? basicInfoData.totalQty : '--' }}</strong> ;
  139. <span>退货总金额:<strong>{{ (basicInfoData&&(basicInfoData.totalPrice || basicInfoData.totalPrice==0)) ? toThousands(basicInfoData.totalPrice) : '--' }}</strong>;</span>
  140. </div>
  141. </a-alert>
  142. <!-- 筛选条件 -->
  143. <a-row :gutter="15">
  144. <a-col :span="17">
  145. <div class="table-page-search-wrapper">
  146. <a-form layout="inline" @keyup.enter.native="$refs.chooseTable.refresh(true)">
  147. <a-row :gutter="15">
  148. <a-col :md="9" :sm="24">
  149. <a-form-item label="产品编码" prop="productCode">
  150. <a-input id="editGrap-productCode" v-model.trim="chooseQueryParam.productCode" placeholder="请输入产品编码" allowClear />
  151. </a-form-item>
  152. </a-col>
  153. <a-col :md="9" :sm="24">
  154. <a-form-item label="产品名称" prop="productName">
  155. <a-input id="editGrap-productName" v-model.trim="chooseQueryParam.productName" placeholder="请输入产品名称" allowClear />
  156. </a-form-item>
  157. </a-col>
  158. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  159. <a-button type="primary" @click="$refs.chooseTable.refresh(true)" :disabled="chooseDisabled" id="editGrap-refresh">查询</a-button>
  160. <a-button style="margin-left: 8px" @click="chooseResetSearchForm" :disabled="chooseDisabled" id="editGrap-reset">重置</a-button>
  161. </a-col>
  162. </a-row>
  163. </a-form>
  164. </div>
  165. </a-col>
  166. <a-col :span="7" style="text-align: right;">
  167. <!-- <a-button size="small" id="editGrap-import-btn" @click="openGuideModal=true">导入产品</a-button> -->
  168. <!-- <a-button size="small" type="danger" style="margin-left: 5px" @click.stop="handleDel('', 'all')" id="chainTransferOutEdit-del-all-btn">整单删除</a-button> -->
  169. </a-col>
  170. </a-row>
  171. <!-- 列表 -->
  172. <s-table
  173. class="sTable"
  174. ref="chooseTable"
  175. size="small"
  176. index="1"
  177. tableId="table2"
  178. :rowKey="(record) => record.id"
  179. :columns="chooseColumns"
  180. :data="chooseLoadData"
  181. :scroll="{ y: 300 }"
  182. :defaultLoadData="false"
  183. bordered>
  184. <!-- 退货数量 -->
  185. <template slot="returnQty" slot-scope="text, record">
  186. <a-input-number
  187. size="small"
  188. v-model="record.returnQty"
  189. :id="'editGrap-returnQty'+record.id"
  190. :precision="0"
  191. :min="1"
  192. :max="99999999"
  193. @blur="e => qtyBlur(e.target.value, record)"
  194. placeholder="请输入"
  195. style="width: 100%;" />
  196. </template>
  197. <!-- 操作 -->
  198. <template slot="action" slot-scope="text, record">
  199. <a-button size="small" type="link" class="button-error" @click="handleDel(record)" :id="'transferReturnEdit-del-btn'+record.id">删除</a-button>
  200. </template>
  201. </s-table>
  202. </a-card>
  203. <!-- </a-spin> -->
  204. </div>
  205. <div class="affix-cont">
  206. <a-button
  207. type="primary"
  208. id="transferReturnEdit-submit"
  209. size="large"
  210. :disabled="spinning"
  211. class="button-primary"
  212. @click="handleSubmit"
  213. style="padding: 0 60px;">提交</a-button>
  214. </div>
  215. <!-- 导入产品 -->
  216. <!-- <importGuideModal :openModal="openGuideModal" :params="{allocateReturnSn: allocateReturnSn}" @close="openGuideModal=false" @ok="handleGuideOk" /> -->
  217. <!-- 修改基础信息 -->
  218. <a-modal
  219. centered
  220. wrapClassName="allocateBill-editRemark-modal"
  221. v-if="basicInfoData"
  222. :footer="null"
  223. :maskClosable="false"
  224. title="修改备注"
  225. v-model="editRemark"
  226. @cancel="editRemark = false"
  227. :width="600">
  228. <a-textarea
  229. id="transferReturnEdit-remarks"
  230. v-model="basicInfoData.remarks"
  231. placeholder="请输入备注(最多120个字符)"
  232. :maxLength="120"
  233. :auto-size="{ minRows: 3, maxRows: 5 }"
  234. />
  235. <div class="btn-cont">
  236. <a-button type="primary" id="transferReturnEdit-save" @click="handleEditRemark">保存</a-button>
  237. <a-button id="transferReturnEdit-cancel" @click="editRemark = false" style="margin-left: 15px;">取消</a-button>
  238. </div>
  239. </a-modal>
  240. </div>
  241. </template>
  242. <script>
  243. import { commonMixin } from '@/utils/mixin'
  244. // 组件
  245. import { STable, VSelect } from '@/components'
  246. // import ImportGuideModal from './importGuideModal.vue'
  247. import print from './print.vue'
  248. import warehouse from '@/views/common/chooseWarehouse.js'
  249. import AllocateType from '@/views/common/allocateType.js'
  250. // 接口
  251. import {
  252. allocateReturnSave,
  253. allocReturnDetailQueryPage,
  254. allocateReturnQueryBySn,
  255. allocReturnDetailInsert,
  256. allocReturnDetailUpdate,
  257. allocateReturnSubmit,
  258. allocReturnDetailDelete,
  259. queryStockProductPage,
  260. stockQueryStockProductPage
  261. } from '@/api/allocateReturn'
  262. export default {
  263. name: 'TransferReturnEdit',
  264. mixins: [commonMixin],
  265. components: { STable, VSelect, print, AllocateType, warehouse },
  266. data () {
  267. const _this = this
  268. return {
  269. spinning: false,
  270. // 查询条件
  271. queryParam: {
  272. productCode: '', // 产品编码
  273. productName: '', // 产品名称
  274. productOrigCode: ''// 原厂编码
  275. },
  276. // 已选列表查询条件
  277. chooseQueryParam: {
  278. productCode: '', // 产品编码
  279. productName: '' // 产品名称
  280. },
  281. editRemark: false, // 编辑备注
  282. disabled: false, // 查询、重置按钮是否可操作
  283. loading: false, // 加载状态
  284. chooseDisabled: false, // 查询、重置按钮是否可操作
  285. advanced: false, // 高级搜索 展开/关闭
  286. dealerLevel: '', // 经销商等级
  287. // 加载数据方法 必须为 Promise 对象
  288. loadData: parameter => {
  289. this.disabled = true
  290. const warehouseSn = _this.basicInfoData.warehouseSn
  291. const dealerLevel = _this.dealerLevel == 'OTHER' ? undefined : _this.dealerLevel
  292. const dealerSnInfo = _this.dealerLevel != 'OTHER' ? _this.basicInfoData.dealerEntity.dealerSn : undefined
  293. const ajaxName = _this.basicInfoData.targetType === 'DEALER' ? queryStockProductPage : stockQueryStockProductPage
  294. // 获取列表数据 有分页
  295. return ajaxName(Object.assign(parameter, this.queryParam, { dealerLevel: dealerLevel === '0' ? '' : dealerLevel, warehouseSn: warehouseSn, dealerSn: dealerSnInfo })).then(res => {
  296. const data = res.data
  297. // 计算表格序号
  298. const no = (data.pageNo - 1) * data.pageSize
  299. for (var i = 0; i < data.list.length; i++) {
  300. data.list[i].no = no + i + 1
  301. data.list[i].qty = 1
  302. if (_this.basicInfoData.targetType === 'DEALER') {
  303. data.list[i].productPrice = data.list[i].priceLevel === 'PROVINCE' ? data.list[i].provincePrice : data.list[i].priceLevel === 'CITY' ? data.list[i].cityPrice : data.list[i].specialPrice
  304. } else {
  305. data.list[i].productPrice = data.list[i].lastStockCost
  306. }
  307. }
  308. this.loadDataSource = data.list || []
  309. this.disabled = false
  310. return data
  311. })
  312. },
  313. loadDataSource: [], // 列表数据
  314. localDataSource: [], // 已选列表数据
  315. allocateReturnSn: '', // 调拨退货sn
  316. // 加载数据方法 必须为 Promise 对象
  317. chooseLoadData: parameter => {
  318. this.chooseDisabled = true
  319. // 获取已选列表数据 有分页
  320. const params = Object.assign(parameter, { product: { name: this.chooseQueryParam.productName, code: this.chooseQueryParam.productCode }, allocateReturnSn: this.allocateReturnSn })
  321. return allocReturnDetailQueryPage(params).then(res => {
  322. const data = res.data
  323. // 计算表格序号
  324. const no = (data.pageNo - 1) * data.pageSize
  325. for (var i = 0; i < data.list.length; i++) {
  326. data.list[i].no = no + i + 1
  327. data.list[i].qtyBackups = data.list[i].returnQty
  328. data.list[i].oldPrice = data.list[i].price
  329. }
  330. this.localDataSource = data.list || []
  331. this.chooseDisabled = false
  332. return data
  333. })
  334. },
  335. basicInfoData: null, // 基本信息
  336. openGuideModal: false, // 导入产品引导
  337. allocateTypeVal: [], // 费用/调拨退货类型 列表数据
  338. showDetail: false// 显示隐藏基础信息
  339. }
  340. },
  341. computed: {
  342. // 表头
  343. columns () {
  344. const _this = this
  345. const arr = [
  346. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  347. { title: '产品编码', dataIndex: 'productCode', width: '10%', align: 'left', customRender: function (text) { return text || '--' } },
  348. { title: '产品名称', dataIndex: 'productName', align: 'left', width: '29%', customRender: function (text) { return text || '--' }, ellipsis: true },
  349. { title: '单位', dataIndex: 'productUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  350. // { title: '价格级别', dataIndex: 'priceLevelDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  351. { title: '退货单价', dataIndex: 'productPrice', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  352. { title: '退货数量', scopedSlots: { customRender: 'returnQty' }, width: '10%', align: 'center' },
  353. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  354. ]
  355. if (_this.basicInfoData && _this.basicInfoData.targetType === 'DEALER') {
  356. arr.splice(4, 0, { title: '价格级别', dataIndex: 'priceLevelDictValue', width: '6%', align: 'center', scopedSlots: { customRender: 'priceLevel' } })
  357. }
  358. return arr
  359. },
  360. // 已选数据表头
  361. chooseColumns () {
  362. const _this = this
  363. const arr = [
  364. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  365. { title: '产品编码', dataIndex: 'product.code', width: '10%', align: 'left', customRender: function (text) { return text || '--' } },
  366. { title: '产品名称', dataIndex: 'product.name', align: 'left', width: '29%', customRender: function (text) { return text || '--' }, ellipsis: true },
  367. { title: '单位', dataIndex: 'product.unit', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  368. { title: '退货单价', dataIndex: 'price', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  369. { title: '退货数量', scopedSlots: { customRender: 'returnQty' }, width: '10%', align: 'center' },
  370. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  371. ]
  372. arr.splice(6, 0, { title: '退货金额', dataIndex: 'totalReturnPrice', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  373. return arr
  374. }
  375. },
  376. methods: {
  377. // 价格等级
  378. handlePriceLevel (val, pos) {
  379. this.loadDataSource[pos].productPrice = val == 'PROVINCE' ? this.loadDataSource[pos].provincePrice : val == 'CITY' ? this.loadDataSource[pos].cityPrice : this.loadDataSource[pos].specialPrice
  380. },
  381. // 修改备注
  382. handleEditRemark (flag) {
  383. const _this = this
  384. const params = _this.basicInfoData
  385. allocateReturnSave(params).then(res => {
  386. if (res.status == 200) {
  387. _this.$message.success(res.message)
  388. _this.getDetail(flag)
  389. } else {
  390. _this.spinning = false
  391. }
  392. })
  393. _this.editRemark = false
  394. },
  395. // 修改仓库
  396. updateWarehouse (warehouseSn) {
  397. this.basicInfoData.warehouseSn = warehouseSn
  398. this.handleEditRemark(true)
  399. },
  400. // 修改调拨类型
  401. changeAllocateType (val, opt) {
  402. console.log(val, opt, '------------')
  403. const _this = this
  404. this.allocateTypeVal = val
  405. this.basicInfoData.costTypeSn = val[0] ? val[0] : ''
  406. this.basicInfoData.allocateSortSn = val[1] ? val[1] : ''
  407. this.basicInfoData.allocateReturnTypeSn = val[2] ? val[2] : ''
  408. // 名称
  409. this.basicInfoData.costTypeName = opt[0] ? opt[0].name : ''
  410. this.basicInfoData.allocateSortName = opt[1] ? opt[1].name : ''
  411. this.basicInfoData.allocateReturnTypeName = opt[2] ? opt[2].name : ''
  412. this.$confirm({
  413. title: '提示',
  414. content: '确定要更改调拨退货类型吗?',
  415. centered: true,
  416. onOk () {
  417. _this.handleEditRemark()
  418. },
  419. onCancel () {
  420. _this.getDetail(false)
  421. }
  422. })
  423. },
  424. // 重置
  425. resetSearchForm () {
  426. this.queryParam.productCode = ''
  427. this.queryParam.productName = ''
  428. this.queryParam.productOrigCode = ''
  429. this.$refs.table.refresh(true)
  430. },
  431. // 双击快速添加
  432. handleClickRow (record) {
  433. return {
  434. on: {
  435. dblclick: (event) => {
  436. this.handleAdd(record)
  437. }
  438. }
  439. }
  440. },
  441. // 导入产品
  442. // handleGuideOk (obj) {
  443. // allocateBillBatchInsert(obj).then(res => {
  444. // if (res.status == 200) {
  445. // this.$refs.chooseTable.refresh(true)
  446. // }
  447. // })
  448. // },
  449. // 已选产品 重置
  450. chooseResetSearchForm () {
  451. this.chooseQueryParam.productCode = ''
  452. this.chooseQueryParam.productName = ''
  453. this.$refs.chooseTable.refresh(true)
  454. },
  455. // 添加/编辑
  456. handleAdd (row, isEdit, isRefresh) {
  457. if (this.dealerLevel === 'DEALER' && !row.priceLevel) {
  458. this.$message.error('请先选择产品价格级别')
  459. return
  460. }
  461. const params = {
  462. allocateReturnSn: this.allocateReturnSn,
  463. productSn: row.productSn,
  464. price: isEdit ? row.price : row.productPrice,
  465. returnQty: isEdit ? row.returnQty : row.qty,
  466. cost: isEdit ? row.cost : row.lastStockCost
  467. }
  468. const fun = isEdit ? allocReturnDetailUpdate : allocReturnDetailInsert
  469. if (isEdit) { // 编辑
  470. // 清空数量时,值应保持未清空前的值,因数量不可为空
  471. if (!row.returnQty) {
  472. row.returnQty = row.qtyBackups
  473. return
  474. }
  475. if (!row.price) {
  476. row.price = row.oldPrice
  477. return
  478. }
  479. params.oldPrice = row.oldPrice
  480. params.allocateReturnDetailSn = row.allocateReturnDetailSn
  481. }
  482. this.spinning = true
  483. fun(params).then(res => {
  484. if (res.status == 200) {
  485. this.getDetail(false)
  486. this.$message.success(res.message)
  487. if (isRefresh != 'noRefresh') {
  488. this.$refs.table.refresh()
  489. }
  490. this.$refs.chooseTable.refresh()
  491. this.spinning = false
  492. } else {
  493. this.spinning = false
  494. }
  495. })
  496. },
  497. // 删除
  498. handleDel (row, isAll) {
  499. const _this = this
  500. const content = isAll ? '删除后不可恢复,确定要进行整单删除吗?' : '删除后不可恢复,确定要进行删除吗?'
  501. this.$confirm({
  502. title: '提示',
  503. content: content,
  504. centered: true,
  505. onOk () {
  506. if (isAll) { // 整单删除
  507. // allocateBillDetailDelAll({ sn: _this.allocateReturnSn }).then(res => {
  508. // if (res.status == 200) {
  509. // _this.$message.success(res.message)
  510. // _this.refashPage()
  511. // }
  512. // })
  513. } else { // 单个删除
  514. allocReturnDetailDelete({
  515. allocateReturnSn: _this.allocateReturnSn,
  516. allocateDetailSn: row.allocateDetailSn,
  517. price: row.price,
  518. productSn: row.productSn
  519. }).then(res => {
  520. if (res.status == 200) {
  521. _this.$message.success(res.message)
  522. _this.refashPage()
  523. }
  524. })
  525. }
  526. }
  527. })
  528. },
  529. // 提交
  530. handleSubmit () {
  531. const _this = this
  532. if (this.localDataSource.length == 0) {
  533. _this.$message.error('请先选择产品!')
  534. return
  535. }
  536. _this.spinning = true
  537. allocateReturnSubmit({ allocateReturnSn: this.allocateReturnSn }).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. })
  548. },
  549. // 基本信息
  550. getDetail (flag) {
  551. this.spinning = true
  552. allocateReturnQueryBySn({ allocateReturnSn: this.allocateReturnSn }).then(res => {
  553. if (res.status == 200) {
  554. this.basicInfoData = res.data
  555. this.dealerLevel = res.data.dealerLevel || '0'
  556. if (this.basicInfoData.costTypeSn) {
  557. this.allocateTypeVal = [this.basicInfoData.costTypeSn, this.basicInfoData.allocateSortSn, this.basicInfoData.allocateReturnTypeSn]
  558. }
  559. if (flag) {
  560. this.$refs.table.refresh()
  561. }
  562. } else {
  563. this.basicInfoData = null
  564. }
  565. this.spinning = false
  566. })
  567. },
  568. // 返回列表
  569. handleBack () {
  570. this.$router.push({ name: 'transferReturnList', query: { closeLastOldTab: true } })
  571. },
  572. // 已选产品 退货数量 blur
  573. qtyBlur (val, record) {
  574. // 光标移出,值发生改变再调用编辑接口
  575. if (val != record.qtyBackups) {
  576. this.handleAdd(record, 'edit')
  577. }
  578. },
  579. // 已选产品 退货单价 change
  580. priceChange (val, record) {
  581. // 光标移出,值发生改变再调用编辑接口
  582. if (val != record.oldPrice) {
  583. this.handleAdd(record, 'edit', 'noRefresh')
  584. }
  585. },
  586. // 刷新当前页面
  587. refashPage () {
  588. this.getDetail(true)
  589. this.$refs.chooseTable.refresh()
  590. },
  591. // 初始化
  592. pageInit () {
  593. this.allocateReturnSn = this.$route.params.sn
  594. this.refashPage()
  595. }
  596. },
  597. mounted () {
  598. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  599. this.pageInit()
  600. }
  601. },
  602. activated () {
  603. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  604. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  605. this.pageInit()
  606. }
  607. },
  608. beforeRouteEnter (to, from, next) {
  609. next(vm => {})
  610. }
  611. }
  612. </script>
  613. <style lang="less">
  614. .transferReturnEdit-wrap{
  615. position: relative;
  616. height: 100%;
  617. box-sizing: border-box;
  618. >.ant-spin-nested-loading{
  619. overflow-y: scroll;
  620. height: 100%;
  621. padding-bottom: 51px;
  622. }
  623. .transferReturnEdit-back{
  624. margin-bottom: 6px;
  625. .ant-page-header-heading-sub-title{
  626. margin:0;
  627. }
  628. }
  629. .transferReturnEdit-cont{
  630. margin-bottom: 6px;
  631. .sub-title{
  632. font-size: 12px;
  633. color: #808695;
  634. margin-left: 10px;
  635. }
  636. .tag-txt{
  637. font-size: 12px;
  638. color: #ed1c24;
  639. }
  640. .edit-circle-btn{
  641. margin-left: 15px;
  642. i{
  643. vertical-align: text-bottom;
  644. }
  645. }
  646. .import-btn{
  647. margin-left: 15px;
  648. }
  649. }
  650. }
  651. .allocateBill-editRemark-modal{
  652. .btn-cont{
  653. text-align: center;
  654. padding-top: 20px;
  655. }
  656. }
  657. </style>