detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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">
  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. <a-card size="small" :bordered="false" class="allocateBillDetail-cont">
  113. <!-- 总计 -->
  114. <div ref="countInfo">
  115. <a-alert type="info" style="margin-bottom:10px">
  116. <div slot="message">
  117. 总数量:<strong>{{ (productTotal&&(productTotal.totalQty || productTotal.totalQty==0)) ? productTotal.totalQty : '--' }}</strong> ;
  118. <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>
  119. <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>
  120. </div>
  121. </a-alert>
  122. </div>
  123. <!-- 列表 -->
  124. <s-table
  125. class="sTable"
  126. ref="table"
  127. size="small"
  128. :rowKey="(record) => record.id"
  129. :columns="columns"
  130. :data="loadData"
  131. :style="{ height:outBizSn? '380px': tableHeight+70+'px' }"
  132. :scroll="{ y:outBizSn?380: tableHeight }"
  133. :defaultLoadData="false"
  134. bordered>
  135. </s-table>
  136. </a-card>
  137. </a-spin>
  138. <!-- 打印导出 -->
  139. <print-modal
  140. :openModal="openModal"
  141. :itemData="basicInfoData"
  142. :nowType="nowType"
  143. @export="exportOk"
  144. @ok="handleOk"
  145. @close="openModal=false" />
  146. </div>
  147. </template>
  148. <script>
  149. import { commonMixin } from '@/utils/mixin'
  150. import { STable, VSelect } from '@/components'
  151. import printModal from './printModal.vue'
  152. import { printBase64Fun, exportExcel } from '@/libs/JGPrint.js'
  153. import { allocateBillDetailList, allocateBillDetail, allocateBillDetailCount, allocateBillDetailPrint, allocateBillDetailExcel } from '@/api/allocateBill'
  154. export default {
  155. name: 'TransferOutDetail',
  156. mixins: [commonMixin],
  157. components: { STable, VSelect, printModal },
  158. props: {
  159. outBizSn: { // 有值则为弹框,无值则为页面
  160. type: [Number, String],
  161. default: ''
  162. }
  163. },
  164. data () {
  165. return {
  166. spinning: false,
  167. // 加载数据方法 必须为 Promise 对象
  168. loadData: parameter => {
  169. this.spinning = true
  170. return allocateBillDetailList(Object.assign(parameter, { allocateSn: this.outBizSn || this.$route.params.sn })).then(res => {
  171. let data
  172. if (res.status == 200) {
  173. data = res.data
  174. const no = (data.pageNo - 1) * data.pageSize
  175. for (var i = 0; i < data.list.length; i++) {
  176. data.list[i].no = no + i + 1
  177. }
  178. this.localDataSource = data.list
  179. }
  180. this.spinning = false
  181. return data
  182. })
  183. },
  184. basicInfoData: null, // 基本信息
  185. productTotal: null, // 合计
  186. localDataSource: [],
  187. openModal: false,
  188. nowType: null,
  189. showDetail: false,
  190. tableHeight: 0
  191. }
  192. },
  193. computed: {
  194. isEdit () {
  195. return this.basicInfoData && ((this.basicInfoData.state == 'WAIT_SUBMIT') || (this.basicInfoData.state == 'WAIT_AUDIT') || (this.basicInfoData.state == 'AUDIT_REJECT')) && this.$hasPermissions('M_transferOut_edit')
  196. },
  197. columns () {
  198. const _this = this
  199. const arr = [
  200. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  201. { title: '产品编码', dataIndex: 'productEntity.code', width: '10%', align: 'left', customRender: function (text) { return text || '--' } },
  202. { title: '产品名称', dataIndex: 'productEntity.name', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  203. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  204. { title: '单位', dataIndex: 'productEntity.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  205. { title: '调出数量', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  206. ]
  207. if (this.$hasPermissions('M_transferOut_detail_costPrice') || this.$hasPermissions('M_tfoPrint_detail_salesPrice') || this.$hasPermissions('M_mso_detail_costPrice')) { // 成本价权限
  208. arr.splice(5, 0, { title: '成本价', dataIndex: 'cost', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  209. arr.splice(8, 0, { title: '成本小计', dataIndex: 'totalCost', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  210. }
  211. if (this.$hasPermissions('M_transferOut_detail_salesPrice') || this.$hasPermissions('M_tfoPrint_detail_salesPrice') || this.$hasPermissions('M_mso_detail_salesPrice')) { // 售价权限
  212. const ind = this.$hasPermissions('M_transferOut_detail_costPrice') || this.$hasPermissions('M_tfoPrint_detail_costPrice') ? 6 : 5
  213. arr.splice(ind, 0, { title: '售价', dataIndex: 'price', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  214. arr.splice(ind + 3, 0, { title: '售价小计', dataIndex: 'totalPrice', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  215. }
  216. arr.push({ title: '费用归属部门', dataIndex: 'departmentName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } })
  217. return arr
  218. }
  219. },
  220. watch: {
  221. showDetail (newValue, oldValue) {
  222. const _this = this
  223. this.$nextTick(() => { // 页面渲染完成后的回调
  224. _this.setTableH()
  225. })
  226. },
  227. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  228. this.setTableH()
  229. }
  230. },
  231. methods: {
  232. // 返回列表
  233. handleBack () {
  234. this.$router.push({ name: 'transferOutList', query: { closeLastOldTab: true } })
  235. },
  236. // 基本信息
  237. getDetail () {
  238. allocateBillDetail({ sn: this.outBizSn || this.$route.params.sn }).then(res => {
  239. if (res.status == 200) {
  240. this.basicInfoData = res.data
  241. } else {
  242. this.basicInfoData = null
  243. }
  244. })
  245. },
  246. // 合计
  247. getDetailCount () {
  248. allocateBillDetailCount({ allocateSn: this.outBizSn || this.$route.params.sn }).then(res => {
  249. if (res.status == 200) {
  250. this.productTotal = res.data
  251. } else {
  252. this.productTotal = null
  253. }
  254. })
  255. },
  256. // 编辑
  257. handleEdit () {
  258. this.$router.push({ path: `/allocationManagement/transferOut/edit/${this.basicInfoData.allocateSn}/${this.basicInfoData.dealerLevel}` })
  259. },
  260. // 打印/导出
  261. handlePrint (type) {
  262. this.nowType = type
  263. this.openModal = true
  264. },
  265. // 导出成功
  266. exportOk (data) {
  267. const _this = this
  268. const filename = this.nowType == 'dbflExport' ? '调拨分类' : '调拨'
  269. this.spinning = true
  270. const params = { allocateSn: this.outBizSn || this.$route.params.sn, ...data }
  271. exportExcel(allocateBillDetailExcel, params, filename, function () {
  272. _this.spinning = false
  273. _this.$store.state.app.curActionPermission = ''
  274. })
  275. },
  276. // 打印成功
  277. handleOk (objs) {
  278. const _this = this
  279. const params = JSON.parse(JSON.stringify(objs))
  280. delete params.type
  281. _this.spinning = true
  282. const taskName = this.nowType == 'dbPrint' ? '调拨' : '调拨分类'
  283. printBase64Fun(
  284. allocateBillDetailPrint,
  285. params,
  286. objs.isPreview ? 'preview' : 'print',
  287. taskName,
  288. () => {
  289. _this.spinning = false
  290. _this.$store.state.app.curActionPermission = ''
  291. },
  292. {
  293. billType: 'ALLOCATE',
  294. billSn: objs.allocateSn,
  295. billNo: objs.allocateNo,
  296. printType: taskName + '打印'
  297. }, !this.basicInfoData.printState || this.basicInfoData.printState == 'UNABLE_PRINT' || this.basicInfoData.printState == 'CANCEL_PRINT')
  298. },
  299. pageInit () {
  300. this.$refs.table.refresh(true)
  301. this.getDetail()
  302. this.getDetailCount()
  303. this.setTableH()
  304. },
  305. setTableH () {
  306. const tableSearchH = this.$refs.tableSearch.offsetHeight
  307. this.tableHeight = window.innerHeight - tableSearchH - 280
  308. }
  309. },
  310. mounted () {
  311. if (!this.$store.state.app.isNewTab || this.outBizSn) { // 页签刷新 或 为弹框时调用
  312. this.pageInit()
  313. }
  314. },
  315. activated () {
  316. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  317. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  318. this.pageInit()
  319. }
  320. },
  321. deactivated () {
  322. this.$store.state.app.curActionPermission = ''
  323. },
  324. beforeRouteEnter (to, from, next) {
  325. next(vm => {})
  326. }
  327. }
  328. </script>
  329. <style lang="less">
  330. .allocateBillDetail-wrap{
  331. .allocateBillDetail-back{
  332. margin-bottom: 6px;
  333. }
  334. .allocateBillDetail-cont{
  335. margin-bottom: 6px;
  336. }
  337. }
  338. </style>