editGrp.vue 27 KB

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