add.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <template>
  2. <div class="expenseReimbursementAddwrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="expenseReimbursementAddcont" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="expenseEdit-back-btn" href="javascript:;" @click="handleBack(0)"><a-icon type="left" /> 返回列表</a>
  8. <span style="margin: 0 15px;color: #666;font-weight: bold;">单号:{{ detailData&&detailData.expenseAccountNo }}</span>
  9. <span style="margin: 0 10px;color: #666;">申请人:{{ detailData&&detailData.applyPersonName || '--' }}</span>
  10. <a-button size="small" type="link" class="button-default" id="expenseEdit-showdesc" @click="showDetail=!showDetail">
  11. <a-icon :type="showDetail ? 'eye-invisible' : 'eye'"/> {{ showDetail?'隐藏':'查看' }}信息
  12. </a-button>
  13. </template>
  14. </a-page-header>
  15. <a-card :bordered="false" size="small" class="expenseReimbursementAddcont" v-show="showDetail">
  16. <div slot="title">
  17. <span>基础信息</span>
  18. <div style="cursor:pointer;color: #00aaff;float:right;" id="expenseEdit-showEditModal" @click.stop="handleEditBase" >
  19. <a-icon type="edit" /> 编辑基础信息
  20. </div>
  21. </div>
  22. <a-descriptions :column="{ xs: 2, sm: 3, md: 3}" v-if="detailData">
  23. <a-descriptions-item label="费用单号">{{ detailData&&detailData.expenseAccountNo || '--' }}</a-descriptions-item>
  24. <a-descriptions-item label="申请人">{{ detailData&&detailData.applyPersonName || '--' }}</a-descriptions-item>
  25. <a-descriptions-item label="申请部门">{{ detailData&&detailData.applyDepartmentName || '--' }}</a-descriptions-item>
  26. <a-descriptions-item label="费用类型">{{ detailData&&detailData.expenseTypeName || '--' }}<span v-if="detailData&&detailData.expenseType2">/{{ detailData&&detailData.expenseTypeName2 || '--' }}</span><span v-if="detailData&&detailData.expenseType3">/{{ detailData&&detailData.expenseTypeName3 || '--' }}</span></a-descriptions-item>
  27. <a-descriptions-item label="费用归属品牌">
  28. {{ (detailData&&detailData.productBrandName) || '--' }}
  29. </a-descriptions-item>
  30. <a-descriptions-item label="费用归属品类">
  31. <div>
  32. <span v-if="detailData&&detailData.productTypeName1">{{ detailData.productTypeName1 || '--' }}</span>
  33. <span v-else>--</span>
  34. <span v-if="detailData&&detailData.productTypeName2">/{{ detailData.productTypeName2 || '--' }}</span>
  35. <span v-if="detailData&&detailData.productTypeName3">/{{ detailData.productTypeName3 || '--' }}</span>
  36. </div>
  37. </a-descriptions-item>
  38. <a-descriptions-item label="费用发生月份">{{ detailData&&detailData.expenseDate?detailData.expenseDate.substring(0, 7) : '--' }}</a-descriptions-item>
  39. <a-descriptions-item label="合计金额">{{ (detailData.applyExpenseTotal || detailData.applyExpenseTotal == 0) ? toThousands(detailData.applyExpenseTotal)+' 元' : '--' }}</a-descriptions-item>
  40. <a-descriptions-item label="状态">{{ detailData&&detailData.stateDictValue || '--' }}</a-descriptions-item>
  41. <a-descriptions-item label="创建时间">{{ detailData&&detailData.createDate || '--' }}</a-descriptions-item>
  42. <a-descriptions-item label="审核时间">{{ detailData&&detailData.finishDate || '--' }}</a-descriptions-item>
  43. <a-descriptions-item label="关联单号" v-if="detailData&&detailData.bizNo">{{ detailData&&detailData.bizNo || '--' }}</a-descriptions-item>
  44. <a-descriptions-item label="主题" :span="3">{{ detailData&&detailData.title || '--' }}</a-descriptions-item>
  45. <a-descriptions-item label="详细说明" :span="4">{{ detailData&&detailData.content.join(',')||'' }}</a-descriptions-item>
  46. <a-descriptions-item label="附件" :span="4">
  47. <a
  48. target="_blank"
  49. style="color: #00aaff;text-decoration: underline;margin-right: 15px;"
  50. :href="item.filePath"
  51. v-for="item in detailData.expenseAccountFilesList"
  52. :id="item.id"
  53. :key="item.id">
  54. {{ item.fileName }}
  55. </a>
  56. </a-descriptions-item>
  57. </a-descriptions>
  58. </a-card>
  59. <!-- 费用明细 -->
  60. <a-card :bordered="false" size="small" class="expenseContent">
  61. <div slot="title">
  62. <div style="display: flex;justify-content: space-between;align-items: center;">
  63. <div>费用明细</div>
  64. <div>
  65. <a-button id="expenseEdit-plEdit" size="small" class="button-info" type="primary" @click="plEdit">变更记账名称</a-button>
  66. <a-button id="expenseEdit-import" size="small" class="button-info" type="primary" @click="openGuideModal=true">导入费用明细</a-button>
  67. <a-button id="expenseEdit-new" size="small" class="button-error" type="primary" @click="newExpenseDetail">新增费用明细</a-button>
  68. </div>
  69. </div>
  70. </div>
  71. <a-alert type="info" style="margin-bottom:10px">
  72. <div slot="message">
  73. 共{{ total }}条费用明细,合计金额{{ detailData&&detailData.applyExpenseTotal?toThousands(detailData.applyExpenseTotal) :'¥0.00' }}元
  74. </div>
  75. </a-alert>
  76. <!-- 列表 -->
  77. <s-table
  78. class="sTable"
  79. ref="table"
  80. size="small"
  81. :rowKey="(record) => record.id"
  82. :columns="columns"
  83. :data="loadData"
  84. :row-selection="{ columnWidth: 40 }"
  85. @rowSelection="rowSelectionFun"
  86. :defaultLoadData="false"
  87. :showPagination="false"
  88. bordered>
  89. <template slot="action" slot-scope="text,record">
  90. <a-button
  91. size="small"
  92. type="link"
  93. class="button-info"
  94. @click="setProduct(record)"
  95. :id="'expenseEdit-set-'+record.id"
  96. >设置产品信息</a-button>
  97. <a-button
  98. size="small"
  99. type="link"
  100. class="button-info"
  101. @click="handleEdit(record)"
  102. :id="'expenseEdit-edit-'+record.id"
  103. >编辑</a-button>
  104. <a-button
  105. size="small"
  106. type="link"
  107. class="button-error"
  108. @click="handleDel(record)"
  109. :id="'expenseEdit-del-'+record.id"
  110. >删除</a-button>
  111. </template>
  112. <!-- 记账名称 -->
  113. <template slot="jzname" slot-scope="text,record">
  114. <div>{{ text }}</div>
  115. <div v-if="record.accountNameFnumber">({{ record.accountNameFnumber }})</div>
  116. </template>
  117. <!-- 原记账名称 -->
  118. <template slot="yjzname" slot-scope="text,record">
  119. <div>{{ text == record.accountName || !text ? '--' : text }}</div>
  120. </template>
  121. <!-- 费用承担方 -->
  122. <template slot="fycdf" slot-scope="text,record">
  123. <div v-for="(item,index) in record.detailSplitList" :key="item.id+'-'+index">
  124. {{ item.splitObjName }}
  125. <span v-if="item.splitObjFnumber">({{ item.splitObjFnumber }})</span>
  126. <span v-if="item.childDetailSplit&&item.childDetailSplit.splitObjName">/</span>
  127. {{ item.childDetailSplit?item.childDetailSplit.splitObjName:'' }}: ¥{{ item.childDetailSplit?item.childDetailSplit.splitAmount:item.splitAmount }}
  128. </div>
  129. </template>
  130. <!-- 产品信息 -->
  131. <template slot="cpxx" slot-scope="text,record">
  132. <div v-if="record.detailProductsList">
  133. <div>
  134. <div v-for="item in record.detailProductsList" :key="item.id">
  135. <div v-if="item.productCode">{{ item.productCode }}</div>
  136. <div v-else-if="item.productBrandName">{{ item.productBrandName }}<span v-if="item.productTypeShowName">/</span>{{ item.productTypeShowName }}</div>
  137. <div v-else>{{ item.productTypeShowName }}</div>
  138. </div>
  139. </div>
  140. </div>
  141. <div v-else>--</div>
  142. </template>
  143. </s-table>
  144. </a-card>
  145. </a-spin>
  146. <div class="affix-cont">
  147. <a-button
  148. type="primary"
  149. class="button-primary"
  150. :disabled="spinning"
  151. id="expenseReimbursementAddsubmit-btn"
  152. size="large"
  153. @click="beforeSubmit"
  154. style="padding: 0 60px;">提交</a-button>
  155. </div>
  156. <!-- 费用明细 -->
  157. <epenseDetailModal
  158. ref="epenseDetailForm"
  159. :openModal="openEpenseDetailModal"
  160. :expenseAccountSn="$route.params.sn"
  161. :expenseAccountNo="detailData?detailData.expenseAccountNo:''"
  162. :expenseAccountDetailSn="expenseAccountDetailSn"
  163. :isBatch="isBatch"
  164. @ok="epenseDetailOk"
  165. @close="epenseDetailClose"></epenseDetailModal>
  166. <!-- 产品信息设置 -->
  167. <productInfoModal
  168. ref="productInfo"
  169. :openModal="openProductInfoModal"
  170. :expenseAccountSn="$route.params.sn"
  171. :expenseAccountNo="detailData?detailData.expenseAccountNo:''"
  172. :expenseAccountDetailSn="expenseAccountDetailSn"
  173. @ok="productInfoOk"
  174. @close="openProductInfoModal=false"></productInfoModal>
  175. <!-- 基础信息编辑 -->
  176. <baseDataModal :show="openBaseModal" @close="openBaseModal=false" :itemSn="$route.params.sn" @refashData="refashData"></baseDataModal>
  177. <!-- 导入费用明细 -->
  178. <ImportGuideModal :openModal="openGuideModal" :params="{expenseAccountSn: $route.params.sn, expenseAccountNo:detailData?detailData.expenseAccountNo:''}" @close="openGuideModal=false" @ok="hanldeImprotOk" />
  179. <!-- 选择审核人员 -->
  180. <chooseDepartUserModal :openModal="openDepartUserModal" @close="openDepartUserModal=false" @submit="handleSubmit"></chooseDepartUserModal>
  181. </div>
  182. </template>
  183. <script>
  184. import { commonMixin } from '@/utils/mixin'
  185. import { VSelect, Upload, STable } from '@/components'
  186. import epenseDetailModal from './epenseDetailModal.vue'
  187. import productInfoModal from './productInfoModal.vue'
  188. import baseDataModal from './baseDataModal.vue'
  189. import ImportGuideModal from './importGuideModal.vue'
  190. import chooseDepartUserModal from './chooseDepartUserModal.vue'
  191. import { expenseAccountDetail, expenseAcctDetailDelete, updateBatchExpenseAcctDetail, expenseAcctDetailFindList, expenseAccountSubmit, expenseInsertImport } from '@/api/expenseManagement.js'
  192. export default {
  193. name: 'ExpenseReimbursementEdit',
  194. mixins: [commonMixin],
  195. components: { VSelect, Upload, STable, epenseDetailModal, productInfoModal, baseDataModal, ImportGuideModal, chooseDepartUserModal },
  196. data () {
  197. const _this = this
  198. return {
  199. spinning: false,
  200. detailData: null, // 详情信息
  201. openBaseModal: false, // 基础信息编辑弹框
  202. openGuideModal: false, // 导入费用明细弹框
  203. openDepartUserModal: false, // 选择审核人员弹框
  204. openEpenseDetailModal: false, // 费用明细弹框
  205. expenseAccountDetailSn: '', // 费用明细sn
  206. openProductInfoModal: false, // 产品信息弹框
  207. showDetail: false, // 是否显示详细信息
  208. total: 0, // 总记录数
  209. loadData: parameter => {
  210. const params = Object.assign(parameter, { expenseAccountSn: this.$route.params.sn })
  211. return expenseAcctDetailFindList(params).then(res => {
  212. let data
  213. if (res.status == 200) {
  214. data = res.data
  215. const no = 0
  216. for (var i = 0; i < data.length; i++) {
  217. data[i].no = no + i + 1
  218. // 产品信息合计
  219. if (data[i].detailProductsList) {
  220. data[i].productTotalAmount = 0
  221. data[i].detailProductsList.map(item => {
  222. data[i].productTotalAmount += item.expense
  223. })
  224. }
  225. }
  226. this.total = data.length
  227. this.disabled = false
  228. this.spinning = false
  229. }
  230. return data
  231. })
  232. },
  233. columns: [
  234. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  235. { title: '记账类型', dataIndex: 'accountTypeDictValue', align: 'center', width: '8%', customRender: function (text) { return text || '--' } },
  236. { title: '记账名称', dataIndex: 'accountName', scopedSlots: { customRender: 'jzname' }, align: 'center', width: '10%' },
  237. { title: '原记账名称', dataIndex: 'origAccountName', scopedSlots: { customRender: 'yjzname' }, align: 'center', width: '10%' },
  238. { title: '所属区域', dataIndex: 'subareaNames', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  239. { title: '所属分区', dataIndex: 'subareaAreaName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  240. { title: '所属省份', dataIndex: 'provinceName', align: 'center', width: '5%', customRender: function (text) { return text || '--' } },
  241. { title: '所属城市', dataIndex: 'cityName', align: 'center', width: '5%', customRender: function (text) { return text || '--' } },
  242. { title: '记账费用', dataIndex: 'expense', align: 'center', width: '8%', customRender: function (text) { return (text == 0 || text) ? _this.toThousands(text) : '--' } },
  243. { title: '费用承担方', scopedSlots: { customRender: 'fycdf' }, align: 'center', width: '15%' },
  244. { title: '产品信息', scopedSlots: { customRender: 'cpxx' }, align: 'center', width: '10%' },
  245. { title: '销售单号', dataIndex: 'salesBillNo', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  246. { title: '备注', dataIndex: 'remarks', align: 'center', width: '10%', customRender: function (text) { return text || '--' } },
  247. { title: '操作', scopedSlots: { customRender: 'action' }, width: '100px', align: 'center' }
  248. ],
  249. isBatch: false, // 是否变更记账名称
  250. rowSelectionInfo: null // 批量选择的数据
  251. }
  252. },
  253. methods: {
  254. // 编辑基础信息
  255. handleEditBase (event) {
  256. this.openBaseModal = true
  257. },
  258. // 刷新列表
  259. refashData () {
  260. this.getDetail(true)
  261. },
  262. // 获取费用单基础详情
  263. getDetail (type) {
  264. this.spinning = true
  265. this.disabled = true
  266. expenseAccountDetail({ expenseAccountSn: this.$route.params.sn }).then(res => {
  267. if (res.status == 200) {
  268. this.detailData = res.data
  269. this.detailData.content = res.data.content.replace(/\n+/, '\n').split('\n')
  270. if (!type) {
  271. // 获取费用明细列表
  272. this.getExpenseDetailList()
  273. } else {
  274. this.spinning = false
  275. this.disabled = false
  276. }
  277. }
  278. })
  279. },
  280. // 查询列表
  281. getExpenseDetailList () {
  282. this.$refs.table.refresh()
  283. },
  284. // 确认导入明细
  285. hanldeImprotOk (obj) {
  286. expenseInsertImport(obj).then(res => {
  287. if (res.status == 200) {
  288. this.getDetail(false)
  289. }
  290. })
  291. },
  292. // 批量修改明细
  293. plEdit () {
  294. if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  295. this.$message.warning('请在列表勾选后再进行操作!')
  296. return
  297. }
  298. this.expenseAccountDetailSn = ''
  299. this.openEpenseDetailModal = true
  300. this.isBatch = true
  301. },
  302. // 表格选中项
  303. rowSelectionFun (obj) {
  304. this.rowSelectionInfo = obj || null
  305. },
  306. // 新增明细
  307. newExpenseDetail () {
  308. this.expenseAccountDetailSn = ''
  309. this.openEpenseDetailModal = true
  310. },
  311. // 编辑明细
  312. handleEdit (row) {
  313. this.openEpenseDetailModal = true
  314. this.expenseAccountDetailSn = row.expenseAccountDetailSn
  315. },
  316. // 新增修改明细成功
  317. epenseDetailOk (data) {
  318. // 如果是批量修改
  319. if (this.isBatch) {
  320. const rows = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  321. const params = []
  322. if (rows.length) {
  323. rows.forEach(item => {
  324. params.push({
  325. expenseAccountDetailSn: item.expenseAccountDetailSn,
  326. origAccountName: item.origAccountName,
  327. origAccountNameSn: item.origAccountNameSn,
  328. accountNameSn: data.accountNameSn,
  329. accountType: data.accountType,
  330. provinceName: data.provinceName,
  331. provinceSn: data.provinceSn,
  332. subareaArea: data.subareaArea,
  333. cityName: data.cityName,
  334. citySn: data.citySn,
  335. expenseAccountNo: data.expenseAccountNo,
  336. expenseAccountSn: data.expenseAccountSn,
  337. remarks: data.remarks
  338. })
  339. })
  340. // 组织数据
  341. updateBatchExpenseAcctDetail(params).then(res => {
  342. if (res.status == 200) {
  343. this.$message.success(res.message)
  344. // 修改成功
  345. this.$refs.table.clearTable()
  346. this.epenseDetailClose()
  347. this.getDetail(false)// 刷新列表
  348. }
  349. this.$refs.epenseDetailForm.spinning = false
  350. })
  351. } else {
  352. this.$message.warning('请在列表勾选后再进行操作!')
  353. this.$refs.epenseDetailForm.spinning = false
  354. }
  355. } else {
  356. // 单个修改成功
  357. this.epenseDetailClose()
  358. this.getDetail(false)// 刷新列表
  359. }
  360. },
  361. // 明细弹框关闭
  362. epenseDetailClose () {
  363. this.openEpenseDetailModal = false
  364. this.isBatch = false
  365. },
  366. // 删除明细
  367. handleDel (row) {
  368. const _this = this
  369. this.$confirm({
  370. title: '提示',
  371. content: '确认要删除吗?',
  372. centered: true,
  373. closable: true,
  374. onOk () {
  375. _this.spinning = true
  376. expenseAcctDetailDelete({ detailSn: row.expenseAccountDetailSn }).then(res => {
  377. if (res.status == 200) {
  378. _this.$message.success(res.message)
  379. _this.getDetail(false)
  380. _this.spinning = false
  381. } else {
  382. _this.spinning = false
  383. }
  384. })
  385. }
  386. })
  387. },
  388. // 设置产品
  389. setProduct (row) {
  390. this.openProductInfoModal = true
  391. this.expenseAccountDetailSn = row.expenseAccountDetailSn
  392. this.$refs.productInfo.setBaseData(row)
  393. },
  394. // 新增产品成功
  395. productInfoOk () {
  396. // 刷新列表
  397. this.openProductInfoModal = false
  398. this.getDetail(false)
  399. },
  400. // 提交前,选择审批人员
  401. beforeSubmit () {
  402. if (this.total) {
  403. this.openDepartUserModal = true
  404. } else {
  405. this.$message.info('请新增费用明细')
  406. }
  407. },
  408. // 提交信息
  409. handleSubmit (data) {
  410. this.spinning = true
  411. expenseAccountSubmit({ expenseAccountSn: this.$route.params.sn, ...data }).then(res => {
  412. if (res.status == '200') {
  413. this.$message.success(res.message)
  414. this.handleBack()
  415. }
  416. this.spinning = false
  417. })
  418. },
  419. // 返回
  420. handleBack (data) {
  421. this.$router.push({ name: 'expenseReimbursementList' })
  422. },
  423. // 初始化页面
  424. pageInit () {
  425. this.$refs.table.clearTable()
  426. if (this.$route.params.sn) { // 编辑页
  427. this.getDetail(false)
  428. }
  429. }
  430. },
  431. mounted () {
  432. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  433. this.pageInit()
  434. }
  435. },
  436. activated () {
  437. this.pageInit()
  438. },
  439. beforeRouteEnter (to, from, next) {
  440. next(vm => {})
  441. }
  442. }
  443. </script>
  444. <style lang="less">
  445. .expenseReimbursementAddwrap{
  446. position: relative;
  447. height: 100%;
  448. padding-bottom: 51px;
  449. box-sizing: border-box;
  450. >.ant-spin-nested-loading{
  451. overflow-y: scroll;
  452. height: 100%;
  453. }
  454. .expenseReimbursementAddcont{
  455. margin-bottom: 6px;
  456. }
  457. .expenseContent{
  458. min-height: calc(100vh - 190px);
  459. }
  460. .upload{
  461. width: 100%!important;
  462. }
  463. .affix{
  464. .ant-affix{
  465. z-index: 101;
  466. }
  467. }
  468. }
  469. </style>