detail.vue 15 KB

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