edit.vue 30 KB

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