edit.vue 30 KB

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