edit.vue 28 KB

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