editGrp.vue 28 KB

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