edit.vue 27 KB

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