edit.vue 28 KB

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