editGrp.vue 27 KB

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