detail.vue 20 KB

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