edit.vue 30 KB

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