edit.vue 25 KB

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