detail.vue 12 KB

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