detail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <div class="allocateBillDetail-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="allocateBillDetail-back" :style="{ padding: !outBizSn ? '16px 24px' : '0px 24px' }" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle" v-if="!outBizSn">
  7. <a id="allocateBillDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <span style="margin: 0 15px;color: #666;font-weight: bold;">单号:{{ basicInfoData&&basicInfoData.allocateNo }}</span>
  9. <a-button
  10. v-if="isEdit"
  11. type="link"
  12. class="button-default"
  13. id="allocateBillDetail-edit-btn"
  14. @click.stop="handleEdit">
  15. <a-icon type="edit"/>编辑
  16. </a-button>
  17. <a-button id="allocateBillDetail-showDetail-btn" type="link" class="button-default" @click="showDetail=!showDetail">
  18. <a-icon :type="showDetail ? 'eye-invisible' : 'eye'"/> {{ showDetail?'隐藏':'查看' }}信息
  19. </a-button>
  20. </template>
  21. <!-- 操作区,位于 title 行的行尾 -->
  22. <template slot="extra">
  23. <a-button
  24. key="4"
  25. type="primary"
  26. class="button-info"
  27. v-if="$hasPermissions('B_transferOut_print')"
  28. id="allocateBillDetail-dbPrint-btn"
  29. :disabled="localDataSource.length==0"
  30. @click="handlePrint('dbPrint')">调拨打印</a-button>
  31. <a-button
  32. key="3"
  33. type="primary"
  34. class="button-info"
  35. v-if="$hasPermissions('B_transferOutType_print')"
  36. id="allocateBillDetail-dbflPrint-btn"
  37. :disabled="localDataSource.length==0"
  38. @click="handlePrint('dbflPrint')">调拨分类打印</a-button>
  39. <a-divider type="vertical" />
  40. <a-button
  41. key="2"
  42. type="default"
  43. class="button-info"
  44. v-if="$hasPermissions('B_transferOut_detail_export')"
  45. id="allocateBillDetail-export-btn"
  46. :disabled="localDataSource.length==0"
  47. @click="handlePrint('dbExport')">导出Excel</a-button>
  48. <a-button
  49. key="1"
  50. type="default"
  51. class="button-info"
  52. v-if="$hasPermissions('B_transferOutType_export')"
  53. id="allocateBillDetail-exportType-btn"
  54. :disabled="localDataSource.length==0"
  55. @click="handlePrint('dbflExport')">调拨分类导出</a-button>
  56. </template>
  57. </a-page-header>
  58. <!-- 基础信息 -->
  59. <div ref="tableSearch" v-if="!outBizSn">
  60. <a-card size="small" :bordered="false" class="allocateBillDetail-cont" v-show="showDetail">
  61. <div style="padding: 0;" ref="basicInformation">
  62. <a-descriptions :column="4">
  63. <a-descriptions-item label="调往对象">{{ (basicInfoData&&basicInfoData.targetName) || '--' }}</a-descriptions-item>
  64. <a-descriptions-item label="调出仓库">{{ (basicInfoData&&basicInfoData.warehouseName) || '--' }}</a-descriptions-item>
  65. <a-descriptions-item label="发货编号">{{ (basicInfoData&&basicInfoData.sendNo) || '--' }}</a-descriptions-item>
  66. <a-descriptions-item label="收货客户名称">{{ (basicInfoData&&basicInfoData.receiverName) || '--' }}</a-descriptions-item>
  67. <a-descriptions-item label="调拨单号">{{ (basicInfoData&&basicInfoData.allocateNo) || '--' }}</a-descriptions-item>
  68. <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
  69. <a-descriptions-item label="打印状态">{{ (basicInfoData&&basicInfoData.printStateDictValue) || '--' }}</a-descriptions-item>
  70. <a-descriptions-item label="费用类型">
  71. {{ (basicInfoData&&basicInfoData.costTypeName) || '--' }}
  72. </a-descriptions-item>
  73. <a-descriptions-item label="调拨类型">
  74. <div>
  75. <span v-if="basicInfoData&&basicInfoData.allocateSortName">{{ basicInfoData.allocateSortName || '--' }}</span>
  76. <span v-if="basicInfoData&&basicInfoData.allocateTypeName">/{{ basicInfoData.allocateTypeName || '--' }}</span>
  77. </div>
  78. </a-descriptions-item>
  79. <a-descriptions-item label="费用归属品牌">
  80. {{ (basicInfoData&&basicInfoData.productBrandName) || '--' }}
  81. </a-descriptions-item>
  82. <a-descriptions-item label="费用归属品类">
  83. <div>
  84. <span v-if="basicInfoData&&basicInfoData.productTypeName1">{{ basicInfoData.productTypeName1 || '--' }}</span>
  85. <span v-else>--</span>
  86. <span v-if="basicInfoData&&basicInfoData.productTypeName2">/{{ basicInfoData.productTypeName2 || '--' }}</span>
  87. <span v-if="basicInfoData&&basicInfoData.productTypeName3">/{{ basicInfoData.productTypeName3 || '--' }}</span>
  88. </div>
  89. </a-descriptions-item>
  90. <a-descriptions-item label="起止时间">
  91. <span v-if="basicInfoData&&(basicInfoData.promoStartDate || basicInfoData.promoEndDate)">{{ (basicInfoData&&basicInfoData.promoStartDate) || '--' }} ~ {{ (basicInfoData&&basicInfoData.promoEndDate) || '--' }}</span>
  92. <span v-else>--</span>
  93. </a-descriptions-item>
  94. <a-descriptions-item label="发货说明" :span="4">
  95. {{ (basicInfoData&&basicInfoData.explainInfo) || '--' }}
  96. </a-descriptions-item>
  97. <a-descriptions-item label="备注" :span="4">{{ (basicInfoData&&basicInfoData.remark) || '--' }}</a-descriptions-item>
  98. <a-descriptions-item label="附件" :span="4">
  99. <div v-if="basicInfoData&&basicInfoData.attachmentList&&basicInfoData.attachmentList.length">
  100. <a
  101. target="_blank"
  102. id="allocateBillDetail-attachmentList"
  103. style="color: #00aaff;text-decoration: underline;margin-right: 15px;"
  104. :href="item.filePath"
  105. v-for="item in basicInfoData.attachmentList"
  106. :key="item.id">
  107. {{ item.fileName }}
  108. </a>
  109. </div>
  110. <span v-else>--</span>
  111. </a-descriptions-item>
  112. </a-descriptions>
  113. </div>
  114. </a-card>
  115. </div>
  116. <div ref="tableSearch" style="padding: 0 12px;" v-else>
  117. <a-collapse :activeKey="['1']">
  118. <a-collapse-panel key="1" header="基础信息">
  119. <a-descriptions :column="4">
  120. <a-descriptions-item label="调往对象">{{ (basicInfoData&&basicInfoData.targetName) || '--' }}</a-descriptions-item>
  121. <a-descriptions-item label="调出仓库">{{ (basicInfoData&&basicInfoData.warehouseName) || '--' }}</a-descriptions-item>
  122. <a-descriptions-item label="发货编号">{{ (basicInfoData&&basicInfoData.sendNo) || '--' }}</a-descriptions-item>
  123. <a-descriptions-item label="收货客户名称">{{ (basicInfoData&&basicInfoData.receiverName) || '--' }}</a-descriptions-item>
  124. <a-descriptions-item label="调拨单号">{{ (basicInfoData&&basicInfoData.allocateNo) || '--' }}</a-descriptions-item>
  125. <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
  126. <a-descriptions-item label="打印状态">{{ (basicInfoData&&basicInfoData.printStateDictValue) || '--' }}</a-descriptions-item>
  127. <a-descriptions-item label="费用类型">
  128. {{ (basicInfoData&&basicInfoData.costTypeName) || '--' }}
  129. </a-descriptions-item>
  130. <a-descriptions-item label="调拨类型">
  131. <div>
  132. <span v-if="basicInfoData&&basicInfoData.allocateSortName">{{ basicInfoData.allocateSortName || '--' }}</span>
  133. <span v-if="basicInfoData&&basicInfoData.allocateTypeName">/{{ basicInfoData.allocateTypeName || '--' }}</span>
  134. </div>
  135. </a-descriptions-item>
  136. <a-descriptions-item label="费用归属品牌">
  137. {{ (basicInfoData&&basicInfoData.productBrandName) || '--' }}
  138. </a-descriptions-item>
  139. <a-descriptions-item label="费用归属品类">
  140. <div>
  141. <span v-if="basicInfoData&&basicInfoData.productTypeName1">{{ basicInfoData.productTypeName1 || '--' }}</span>
  142. <span v-else>--</span>
  143. <span v-if="basicInfoData&&basicInfoData.productTypeName2">/{{ basicInfoData.productTypeName2 || '--' }}</span>
  144. <span v-if="basicInfoData&&basicInfoData.productTypeName3">/{{ basicInfoData.productTypeName3 || '--' }}</span>
  145. </div>
  146. </a-descriptions-item>
  147. <a-descriptions-item label="起止时间">
  148. <span v-if="basicInfoData&&(basicInfoData.promoStartDate || basicInfoData.promoEndDate)">{{ (basicInfoData&&basicInfoData.promoStartDate) || '--' }} ~ {{ (basicInfoData&&basicInfoData.promoEndDate) || '--' }}</span>
  149. <span v-else>--</span>
  150. </a-descriptions-item>
  151. <a-descriptions-item label="备注" :span="4">{{ (basicInfoData&&basicInfoData.remark) || '--' }}</a-descriptions-item>
  152. <a-descriptions-item label="附件" :span="4">
  153. <div v-if="basicInfoData&&basicInfoData.attachmentList&&basicInfoData.attachmentList.length">
  154. <a
  155. target="_blank"
  156. id="allocateBillDetail-attachmentList"
  157. style="color: #00aaff;text-decoration: underline;margin-right: 15px;"
  158. :href="item.filePath"
  159. v-for="item in basicInfoData.attachmentList"
  160. :key="item.id">
  161. {{ item.fileName }}
  162. </a>
  163. </div>
  164. <span v-else>--</span>
  165. </a-descriptions-item>
  166. </a-descriptions>
  167. </a-collapse-panel>
  168. </a-collapse>
  169. </div>
  170. <a-card size="small" :bordered="false" class="allocateBillDetail-cont">
  171. <!-- 总计 -->
  172. <div ref="countInfo">
  173. <a-alert type="info" style="margin-bottom:10px">
  174. <div slot="message">
  175. 总数量:<strong>{{ (productTotal&&(productTotal.totalQty || productTotal.totalQty==0)) ? productTotal.totalQty : '--' }}</strong> ;
  176. <span v-if="$hasPermissions('M_transferOut_detail_costPrice')||$hasPermissions('M_tfoPrint_detail_costPrice')||$hasPermissions('M_mso_detail_costPrice')">总成本:<strong>{{ (productTotal&&(productTotal.totalCost || productTotal.totalCost==0)) ? toThousands(productTotal.totalCost) : '--' }}</strong> ;</span>
  177. <span v-if="$hasPermissions('M_transferOut_detail_salesPrice')||$hasPermissions('M_tfoPrint_detail_salesPrice')||$hasPermissions('M_mso_detail_salesPrice')">总售价:<strong>{{ (productTotal&&(productTotal.totalPrice || productTotal.totalPrice==0)) ? toThousands(productTotal.totalPrice) : '--' }}</strong>;</span>
  178. </div>
  179. </a-alert>
  180. </div>
  181. <!-- 列表 -->
  182. <s-table
  183. class="sTable"
  184. ref="table"
  185. size="small"
  186. :rowKey="(record) => record.id"
  187. :columns="columns"
  188. :data="loadData"
  189. :style="{ height:outBizSn? '380px': tableHeight+70+'px' }"
  190. :scroll="{ y:outBizSn?380: tableHeight }"
  191. :defaultLoadData="false"
  192. bordered>
  193. </s-table>
  194. </a-card>
  195. </a-spin>
  196. <!-- 打印导出 -->
  197. <print-modal
  198. :openModal="openModal"
  199. :itemData="basicInfoData"
  200. :nowType="nowType"
  201. @export="exportOk"
  202. @ok="handleOk"
  203. @close="openModal=false" />
  204. </div>
  205. </template>
  206. <script>
  207. import { commonMixin } from '@/utils/mixin'
  208. // 组件
  209. import { STable, VSelect } from '@/components'
  210. import printModal from './printModal.vue'
  211. import { printBase64Fun, exportExcel } from '@/libs/JGPrint.js'
  212. // 接口
  213. import { allocateBillDetailList, allocateBillDetail, allocateBillDetailCount, allocateBillDetailPrint, allocateBillDetailExcel } from '@/api/allocateBill'
  214. export default {
  215. name: 'TransferOutDetail',
  216. mixins: [commonMixin],
  217. components: { STable, VSelect, printModal },
  218. props: {
  219. outBizSn: { // 有值则为弹框,无值则为页面
  220. type: [Number, String],
  221. default: ''
  222. }
  223. },
  224. data () {
  225. return {
  226. spinning: false,
  227. // 加载数据方法 必须为 Promise 对象
  228. loadData: parameter => {
  229. this.spinning = true
  230. // 获取列表数据 有分页
  231. return allocateBillDetailList(Object.assign(parameter, { allocateSn: this.outBizSn || this.$route.params.sn })).then(res => {
  232. let data
  233. if (res.status == 200) {
  234. data = res.data
  235. // 计算表格序号
  236. const no = (data.pageNo - 1) * data.pageSize
  237. for (var i = 0; i < data.list.length; i++) {
  238. data.list[i].no = no + i + 1
  239. }
  240. this.localDataSource = data.list
  241. }
  242. this.spinning = false
  243. return data
  244. })
  245. },
  246. basicInfoData: null, // 基本信息
  247. productTotal: null, // 合计
  248. localDataSource: [], // 表格数据
  249. openModal: false, // 打印导出弹窗
  250. nowType: null, // dbflExport 调拨分类 dbPrint调拨
  251. showDetail: false, // 显示隐藏基础信息
  252. tableHeight: 0// 计算表格高度
  253. }
  254. },
  255. computed: {
  256. // 是否显示基础信息编辑按钮
  257. isEdit () {
  258. return this.basicInfoData && ((this.basicInfoData.state == 'WAIT_SUBMIT') || (this.basicInfoData.state == 'WAIT_AUDIT') || (this.basicInfoData.state == 'AUDIT_REJECT')) && this.$hasPermissions('M_transferOut_edit')
  259. },
  260. // 表头
  261. columns () {
  262. const _this = this
  263. const arr = [
  264. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  265. { title: '产品编码', dataIndex: 'productEntity.code', width: '10%', align: 'left', customRender: function (text) { return text || '--' } },
  266. { title: '产品名称', dataIndex: 'productEntity.name', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  267. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  268. { title: '单位', dataIndex: 'productEntity.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  269. // { title: '价格级别', dataIndex: 'priceLevelDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  270. { title: '调出数量', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  271. ]
  272. if (this.$hasPermissions('M_transferOut_detail_costPrice') || this.$hasPermissions('M_tfoPrint_detail_salesPrice') || this.$hasPermissions('M_mso_detail_costPrice')) { // 成本价权限
  273. arr.splice(5, 0, { title: '成本价', dataIndex: 'cost', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  274. arr.splice(8, 0, { title: '成本小计', dataIndex: 'totalCost', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  275. }
  276. if (this.$hasPermissions('M_transferOut_detail_salesPrice') || this.$hasPermissions('M_tfoPrint_detail_salesPrice') || this.$hasPermissions('M_mso_detail_salesPrice')) { // 售价权限
  277. const ind = this.$hasPermissions('M_transferOut_detail_costPrice') || this.$hasPermissions('M_tfoPrint_detail_costPrice') ? 6 : 5
  278. arr.splice(ind, 0, { title: '售价', dataIndex: 'price', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  279. arr.splice(ind + 4, 0, { title: '售价小计', dataIndex: 'totalPrice', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  280. }
  281. if (this.basicInfoData && this.basicInfoData.targetType === 'DEALER') {
  282. arr.splice(7, 0, { title: '价格级别', dataIndex: 'priceLevelDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } })
  283. }
  284. arr.push({ title: '费用归属部门', dataIndex: 'departmentName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } })
  285. return arr
  286. }
  287. },
  288. watch: {
  289. // 基础信息显示关闭 表格高度变化
  290. showDetail (newValue, oldValue) {
  291. const _this = this
  292. this.$nextTick(() => { // 页面渲染完成后的回调
  293. _this.setTableH()
  294. })
  295. },
  296. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  297. this.setTableH()
  298. }
  299. },
  300. methods: {
  301. // 返回列表
  302. handleBack () {
  303. this.$router.push({ name: 'transferOutList', query: { closeLastOldTab: true } })
  304. },
  305. // 基本信息
  306. getDetail () {
  307. allocateBillDetail({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  308. if (res.status == 200) {
  309. this.basicInfoData = res.data
  310. } else {
  311. this.basicInfoData = null
  312. }
  313. })
  314. },
  315. // 合计
  316. getDetailCount () {
  317. allocateBillDetailCount({ allocateSn: this.outBizSn || this.$route.params.sn }).then(res => {
  318. if (res.status == 200) {
  319. this.productTotal = res.data
  320. } else {
  321. this.productTotal = null
  322. }
  323. })
  324. },
  325. // 编辑
  326. handleEdit () {
  327. this.$router.push({ path: `/allocationManagement/transferOut/edit/${this.basicInfoData.allocateSn}/${this.basicInfoData.dealerLevel}` })
  328. },
  329. // 打印/导出
  330. handlePrint (type) {
  331. this.nowType = type
  332. this.openModal = true
  333. },
  334. // 导出成功
  335. exportOk (data) {
  336. const _this = this
  337. const filename = this.nowType == 'dbflExport' ? '调拨分类' : '调拨'
  338. this.spinning = true
  339. const params = { allocateSn: this.outBizSn || this.$route.params.sn, ...data }
  340. exportExcel(allocateBillDetailExcel, params, filename, function () {
  341. _this.spinning = false
  342. _this.$store.state.app.curActionPermission = ''
  343. })
  344. },
  345. // 打印成功
  346. handleOk (objs) {
  347. const _this = this
  348. const params = JSON.parse(JSON.stringify(objs))
  349. delete params.type
  350. _this.spinning = true
  351. const taskName = this.nowType == 'dbPrint' ? '调拨' : '调拨分类'
  352. printBase64Fun(
  353. allocateBillDetailPrint,
  354. params,
  355. objs.isPreview ? 'preview' : 'print',
  356. taskName,
  357. () => {
  358. _this.spinning = false
  359. _this.$store.state.app.curActionPermission = ''
  360. },
  361. {
  362. billType: 'ALLOCATE',
  363. billSn: objs.allocateSn,
  364. billNo: objs.allocateNo,
  365. printType: taskName + '打印'
  366. }, !this.basicInfoData.printState || this.basicInfoData.printState == 'UNABLE_PRINT' || this.basicInfoData.printState == 'CANCEL_PRINT')
  367. },
  368. // 初始化
  369. pageInit () {
  370. this.$refs.table.refresh(true)
  371. this.getDetail()
  372. this.getDetailCount()
  373. this.setTableH()
  374. },
  375. // 计算表格高度
  376. setTableH () {
  377. const tableSearchH = this.$refs.tableSearch.offsetHeight
  378. this.tableHeight = window.innerHeight - tableSearchH - 280
  379. }
  380. },
  381. mounted () {
  382. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新 或 为弹框时调用
  383. this.pageInit()
  384. }
  385. },
  386. activated () {
  387. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  388. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  389. this.pageInit()
  390. }
  391. },
  392. deactivated () {
  393. this.$store.state.app.curActionPermission = ''
  394. },
  395. beforeRouteEnter (to, from, next) {
  396. next(vm => {})
  397. }
  398. }
  399. </script>
  400. <style lang="less">
  401. .allocateBillDetail-wrap{
  402. .allocateBillDetail-back{
  403. margin-bottom: 6px;
  404. }
  405. .allocateBillDetail-cont{
  406. margin-bottom: 6px;
  407. }
  408. }
  409. </style>