editGrp.vue 27 KB

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