balanceSheetEdit.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <div class="balance-sheet-detail-wrap">
  3. <noDataAuth class="no-auth-box" v-if="!excelInfo.HaveOperaAuth&&isView" :text="$t('MsgPrompt.no_sheet_auth')"/>
  4. <div class="wrap-top">
  5. <ul class="form-ul">
  6. <li>
  7. <el-input
  8. v-model="sheetForm.name"
  9. :placeholder="$t('OnlineExcelPage.please_table_name_ipt')"
  10. style="width: 200px"
  11. clearable
  12. :disabled="isView||isStaticTable"
  13. >
  14. </el-input>
  15. </li>
  16. <li>
  17. <el-cascader
  18. v-model="sheetForm.classify"
  19. :options="classifyArr"
  20. style="width: 120px"
  21. :props="{
  22. label: 'ExcelClassifyName',
  23. value: 'ExcelClassifyId',
  24. children: 'Children',
  25. emitPath: false,
  26. checkStrictly: true,
  27. }"
  28. :placeholder="$t('OnlineExcelPage.select_table_category')"
  29. :disabled="isView||isStaticTable"
  30. />
  31. </li>
  32. <li v-if="excelInfo.Button&&excelInfo.Button.OpWorkerButton">
  33. <el-cascader
  34. v-model="sheetForm.user"
  35. :options="userList"
  36. style="width: 120px"
  37. :show-all-levels="false"
  38. collapse-tags
  39. :props="{
  40. label: 'NodeName',
  41. value: 'NodeId',
  42. children: 'Children',
  43. multiple: true,
  44. emitPath: false,
  45. checkStrictly: false,
  46. }"
  47. clearable
  48. :placeholder="$t('OnlineExcelPage.Co_editor')"
  49. :disabled="isView||isStaticTable"
  50. />
  51. </li>
  52. </ul>
  53. <div class="form-ul">
  54. <span>{{ $t("BalanceSheet.version") }}</span>
  55. <el-select
  56. v-model="sheetForm.version"
  57. style="width: 90px; margin-right: 5px"
  58. @change="handleVersionChange"
  59. >
  60. <el-option
  61. v-for="item in versionOpts"
  62. :key="item.ExcelInfoId"
  63. :label="item.VersionName"
  64. :value="item.ExcelInfoId"
  65. ></el-option>
  66. </el-select>
  67. <!-- 存为静态表按钮 -->
  68. <el-button type="primary" @click="handleShowSaveStaticTable" v-if="!isView&&!isStaticTable">{{
  69. $t("BalanceSheet.save_static_table")
  70. }}</el-button>
  71. <!-- 静态表操作 -->
  72. <span v-if="!isView&&isStaticTable">
  73. <span
  74. class="editsty"
  75. @click="handleShowSaveStaticTable('rename')"
  76. style="margin-right: 10px"
  77. >{{$t('MyEtaPage.option_op_rename')}}</span
  78. >
  79. <span
  80. class="deletesty"
  81. @click="handleStaticTableDel"
  82. >{{$t("Table.delete_btn")}}</span
  83. >
  84. </span>
  85. <div>
  86. <el-tooltip effect="dark">
  87. <div
  88. slot="content"
  89. v-html="rules"
  90. style="line-height: 20px; width: 350px"
  91. ></div>
  92. <i class="el-icon-question" />
  93. </el-tooltip>
  94. </div>
  95. </div>
  96. <div>
  97. <span v-if="updateTime" style="color: #999999"
  98. >{{ $t("OnlineExcelPage.recent_save_time_info")
  99. }}{{ updateTime }}</span
  100. >
  101. <!-- 预览页面操作按钮 -->
  102. <template v-if="isView">
  103. <span
  104. class="editsty"
  105. @click="itemHandle(excelInfo, 'edit')"
  106. style="margin-right: 10px"
  107. v-if="isSheetBtnShow('edit')&&excelInfo.Button&&excelInfo.Button.OpButton"
  108. >{{excelInfo.CanEdit?$t("ETable.Btn.edit_btn"):excelInfo.Editor+$t('OnlineExcelPage.editing_msg')}}</span
  109. >
  110. <span
  111. class="editsty"
  112. @click="itemHandle(excelInfo, 'refresh')"
  113. style="margin-right: 10px"
  114. v-if="isSheetBtnShow('refresh')&&excelInfo.Button&&excelInfo.Button.RefreshButton"
  115. >{{ $t("ETable.Btn.refresh_btn") }}</span
  116. >
  117. <span
  118. class="editsty"
  119. @click="itemHandle(excelInfo, 'save')"
  120. style="margin-right: 10px"
  121. v-if="isSheetBtnShow('otherSave')&&excelInfo.Button&&excelInfo.Button.CopyButton"
  122. >{{ $t("ETable.Btn.save_as") }}</span
  123. >
  124. <span
  125. class="editsty"
  126. @click="itemHandle(excelInfo, 'download')"
  127. style="margin-right: 10px"
  128. v-if="isSheetBtnShow('download')&&excelInfo.HaveOperaAuth"
  129. >{{ $t("ETable.Btn.download_btn") }}</span
  130. >
  131. <span
  132. class="deletesty"
  133. @click="itemHandle(excelInfo, 'del')"
  134. style="margin-right: 10px"
  135. v-if="isSheetBtnShow('del')&&excelInfo.Button&&excelInfo.Button.DeleteButton"
  136. >{{ $t("Table.delete_btn") }}</span
  137. >
  138. </template>
  139. <el-button
  140. type="primary"
  141. size="medium"
  142. :loading="updating"
  143. @click="updateHandle"
  144. style="margin-left: 10px"
  145. v-if="!isView"
  146. >{{
  147. updating
  148. ? $t("ETable.Btn.renewing_btn")
  149. : $t("ETable.Btn.renew_btn")
  150. }}</el-button
  151. >
  152. <el-button
  153. type="primary"
  154. size="medium"
  155. @click="saveSheetHandle"
  156. style="margin-left: 10px"
  157. v-if="!isView"
  158. >{{ $t("ETable.Btn.save_btn") }}</el-button
  159. >
  160. <el-button type="primary" size="medium" plain @click="backHandle">{{
  161. $t("ETable.Btn.back_btn")
  162. }}</el-button>
  163. </div>
  164. </div>
  165. <BalanceTable
  166. ref="balanceTableRef"
  167. :disabled="isView"
  168. :isStaticTable="isStaticTable"
  169. />
  170. <!-- 存为静态表弹窗 -->
  171. <el-dialog
  172. :visible.sync="showSaveStaticTable"
  173. :close-on-click-modal="false"
  174. :modal-append-to-body='false'
  175. :title="isStaticTable?$t('MyEtaPage.option_op_rename'):$t('OnlineExcelPage.save_static_table')"
  176. @close="showSaveStaticTable=false"
  177. custom-class="dialog"
  178. center
  179. width="500px"
  180. v-dialogDrag
  181. >
  182. <div style="text-align:center">
  183. <span>{{$t('OnlineExcelPage.static_table_version_name')}}</span>
  184. <el-input v-model="staticTableName" :placeholder="$t('OnlineExcelPage.save_static_table_tip')"></el-input>
  185. </div>
  186. <div class="dia-bot" style="text-align:center;padding:30px 0">
  187. <el-button type="primary" style="margin-right:20px" @click="createdStaticTable">{{$t('ETable.Btn.save_btn')}}</el-button>
  188. <el-button type="primary" plain @click="showSaveStaticTable=false">{{$t('ETable.Btn.cancel_btn')}}</el-button>
  189. </div>
  190. </el-dialog>
  191. <!-- 表格另存 -->
  192. <m-dialog
  193. :show.sync="isSaveOther"
  194. width="650px"
  195. :title="$t('ETable.Btn.save_as')"
  196. @close="cancelSaveOther"
  197. >
  198. <div style="padding-left: 80px">
  199. <el-form
  200. ref="formRef"
  201. label-position="left"
  202. hide-required-asterisk
  203. label-width="80px"
  204. :model="saveOtherForm"
  205. :rules="saveOtherFormRule"
  206. >
  207. <el-form-item :label="$t('OnlineExcelPage.excel_name_ipt')" prop="name">
  208. <el-input
  209. v-model="saveOtherForm.name"
  210. style="width: 80%"
  211. :placeholder="$t('OnlineExcelPage.please_table_name_ipt')"
  212. />
  213. </el-form-item>
  214. <el-form-item :label="$t('OnlineExcelPage.table_classification_label')" prop="classify">
  215. <el-cascader
  216. v-model="saveOtherForm.classify"
  217. :options="classifyArr"
  218. :props="{
  219. label: 'ExcelClassifyName',
  220. value: 'ExcelClassifyId',
  221. children: 'Children',
  222. emitPath: false,
  223. checkStrictly: true,
  224. }"
  225. style="width: 80%"
  226. :placeholder="$t('OnlineExcelPage.select_appropriate_category_lable')"
  227. class="sheet-classify-cascader"
  228. />
  229. </el-form-item>
  230. </el-form>
  231. </div>
  232. <div style="display: flex; justify-content: center; margin-top: 30px">
  233. <el-button
  234. type="primary"
  235. style="margin-right: 60px"
  236. @click="saveCopyOther"
  237. >{{$t('Dialog.confirm_save_btn')}}</el-button
  238. >
  239. <el-button type="primary" plain @click="cancelSaveOther"
  240. >{{$t('Dialog.cancel_btn')}}</el-button
  241. >
  242. </div>
  243. </m-dialog>
  244. </div>
  245. </template>
  246. <script>
  247. import * as sheetInterface from '@/api/modules/sheetApi.js';
  248. import { departInterence } from "@/api/api.js";
  249. import moment from 'moment';
  250. import mDialog from "@/components/mDialog.vue";
  251. import BalanceTable from './components/BalanceTable.vue';
  252. import BalanceTableMixin from './mixins/balanceTableMixin'
  253. export default {
  254. mixins:[BalanceTableMixin],
  255. components: {
  256. BalanceTable,
  257. mDialog
  258. },
  259. computed: {
  260. downExcelFileUrl() {
  261. let url = `${
  262. process.env.VUE_APP_API_ROOT
  263. }/datamanage/excel_info/table/download?${localStorage.getItem("auth")}`;
  264. return url;
  265. },
  266. rules() {
  267. return this.$t('OnlineExcelPage.TablebalanceMixText') || ''
  268. },
  269. isView(){
  270. return this.$route.path==='/viewBalanceSheet'
  271. },
  272. // 当前是否为静态表
  273. isStaticTable(){
  274. let flag=false
  275. this.versionOpts.forEach(item=>{
  276. if(item.ExcelInfoId===this.sheetForm.version&&item.BalanceType==1){
  277. flag=true
  278. }
  279. })
  280. return flag
  281. },
  282. saveOtherFormRule(){
  283. return {
  284. name: [
  285. { required: true, message: this.$t('OnlineExcelPage.table_name_empty_msg') , trigger: "blur" },
  286. ],
  287. classify: [
  288. { required: true, message: this.$t('OnlineExcelPage.cannot_be_empty_table') , trigger: "blur" },
  289. ],
  290. }
  291. }
  292. },
  293. data() {
  294. return {
  295. sheetId: this.$route.query.id || '',
  296. excelInfo:{},
  297. updating:false,
  298. sheetForm: {
  299. name: '',
  300. classify: '',
  301. user: '',
  302. version: Number(this.$route.query.id),
  303. },
  304. classifyArr: [],
  305. userList: [],//系统用户
  306. updateTime: moment().format('YYYY-MM-DD HH:mm:ss'),
  307. versionOpts: [],
  308. showSaveStaticTable:false,//存为静态表弹窗
  309. staticTableName:moment().format('YYYY-MM-DD'),
  310. /* 另存为 */
  311. isSaveOther: false,
  312. saveOtherForm: {
  313. name: '',
  314. classify: ''
  315. },
  316. }
  317. },
  318. created() {
  319. this.getClassify();
  320. this.getSystemUserList()
  321. this.getChildTable()
  322. this.getDetail()
  323. this.getVersionList()
  324. },
  325. beforeRouteLeave(to,from,next){
  326. console.log('退出编辑',from);
  327. if(from.path==='/editBalanceSheet'){
  328. this.markFinishStatus()
  329. }
  330. next()
  331. },
  332. methods: {
  333. // 获取版本列表
  334. getVersionList(){
  335. sheetInterface.balanceTableVersion({ExcelInfoId:this.sheetId}).then(res=>{
  336. if(res.Ret===200){
  337. const arr=res.Data.List||[]
  338. if(this.$i18nt.locale!=='zh'){
  339. arr[0].VersionName='Active'
  340. }
  341. this.versionOpts=arr
  342. }
  343. })
  344. },
  345. handleVersionChange(){
  346. this.getChildTable()
  347. },
  348. cancelSaveOther() {
  349. this.$refs.formRef.resetFields();
  350. this.saveOtherForm = {
  351. name: '',
  352. classify: ''
  353. };
  354. this.isSaveOther = false;
  355. },
  356. /* 另存为 */
  357. async saveCopyOther() {
  358. await this.$refs.formRef.validate();
  359. let { classify, name } = this.saveOtherForm;
  360. const res = await sheetInterface.copyExcel({
  361. ExcelInfoId: this.excelInfo.ExcelInfoId,
  362. ExcelName: name,
  363. ExcelClassifyId: classify,
  364. });
  365. if (res.Ret !== 200) return;
  366. this.$message.success(this.$t('MsgPrompt.saved_msg') );
  367. this.cancelSaveOther();
  368. },
  369. handleShowSaveStaticTable(type){
  370. console.log(type);
  371. if(type==='rename'){
  372. this.versionOpts.forEach(item=>{
  373. if(item.ExcelInfoId===this.sheetForm.version){
  374. this.staticTableName=item.VersionName
  375. }
  376. })
  377. }else{
  378. this.staticTableName=this.$moment().format('YYYY-MM-DD')
  379. }
  380. this.showSaveStaticTable=true
  381. },
  382. // 创建/重命名静态表
  383. createdStaticTable(){
  384. if(!this.staticTableName){
  385. this.$message.warning(this.$t('OnlineExcelPage.save_static_table_tip'))
  386. return
  387. }
  388. // 重命名
  389. if(this.isStaticTable){
  390. sheetInterface.balanceStaticTableRename({
  391. ExcelInfoId:Number(this.sheetForm.version),
  392. VersionName:this.staticTableName
  393. }).then(res=>{
  394. if(res.Ret===200){
  395. this.$message.success(res.Msg);
  396. this.getVersionList()
  397. this.showSaveStaticTable=false
  398. this.$refs.balanceTableRef.getChartList()//更新图表数据
  399. }
  400. })
  401. return
  402. }
  403. sheetInterface.balanceTableSaveStatic({
  404. ExcelInfoId:Number(this.sheetForm.version),
  405. VersionName:this.staticTableName
  406. }).then(res=>{
  407. if(res.Ret===200){
  408. this.getVersionList()
  409. this.sheetForm.version=res.Data.ExcelInfoId
  410. this.getChildTable()
  411. this.showSaveStaticTable=false
  412. }
  413. })
  414. },
  415. // 删除当前静态表
  416. handleStaticTableDel(){
  417. this.$confirm(this.$t('ETable.Msg.is_del_table_msg') , this.$t('Confirm.prompt') , {
  418. confirmButtonText: this.$t('Dialog.confirm_btn'),
  419. cancelButtonText: this.$t('Dialog.cancel_btn'),
  420. type: "warning",
  421. }).then(()=>{
  422. sheetInterface.classifyDel({
  423. ExcelClassifyId:0,
  424. ExcelInfoId:Number(this.sheetForm.version),
  425. Source: 5
  426. }).then(res=>{
  427. if(res.Ret===200){
  428. this.$message.success(res.Msg);
  429. this.sheetForm.version=Number(this.sheetId)
  430. this.getVersionList()
  431. this.getChildTable()
  432. }
  433. })
  434. }).catch(()=>{})
  435. },
  436. //获取所有子表数据
  437. async getChildTable(){
  438. if(!this.sheetForm.version) return
  439. const res = await sheetInterface.getBalanceChildTable({
  440. ParentId: Number(this.sheetForm.version)
  441. })
  442. if(res.Ret !== 200) return
  443. this.$refs.balanceTableRef.initSheetListData(res.Data.List||[]);
  444. },
  445. /* 获取表格详情 */
  446. async getDetail(type='init') {
  447. if(!this.sheetId) return
  448. const res = await sheetInterface.sheetDetail({
  449. ExcelInfoId: Number(this.sheetId)
  450. })
  451. if(res.Ret !== 200) return
  452. this.excelInfo=res.Data
  453. const { ExcelName,ExcelClassifyId,TableData,ModifyTime,Button } = res.Data;
  454. this.sheetForm.name=ExcelName
  455. this.sheetForm.classify=ExcelClassifyId
  456. this.getTableWorker()
  457. },
  458. // 保存父表基础信息
  459. async saveTableInfo(){
  460. let params = {
  461. ExcelInfoId:Number(this.sheetId),
  462. ExcelName: this.sheetForm.name,
  463. ExcelType: 1,
  464. ExcelClassifyId: this.sheetForm.classify,
  465. ExcelImage: '',
  466. Source: 5,
  467. TableData: {
  468. CellRelation:"[]",
  469. Data:[]
  470. }
  471. };
  472. const res=await sheetInterface.sheetEdit(params)
  473. },
  474. //获取协作人
  475. async getTableWorker(){
  476. const res=await sheetInterface.getBalanceTableWorker({
  477. ExcelInfoId:Number(this.sheetId)
  478. })
  479. if(res.Ret !== 200) return
  480. const arr=res.Data.List||[]
  481. this.sheetForm.user=arr.map(e=>e.SysUserId)
  482. },
  483. // 保存设置的协作人
  484. async setTableWorker(){
  485. if(!this.excelInfo.Button.OpWorkerButton) return
  486. const res=await sheetInterface.setBalanceTableWorker({
  487. ExcelInfoId:Number(this.sheetId),
  488. SysUserIds:this.sheetForm.user?this.sheetForm.user.join(','):''
  489. })
  490. if(res.Ret !== 200) return
  491. },
  492. //点击保存
  493. saveSheetHandle(){
  494. this.setTableWorker()// 保存协作人
  495. this.saveTableInfo()// 保存父表基础信息
  496. this.$refs.balanceTableRef.saveChildSheet('manualSave')
  497. this.$refs.balanceTableRef.getChartList()//更新图表数据
  498. },
  499. // 点击更新
  500. async updateHandle(){
  501. if(this.updating) return
  502. this.updating=true
  503. // 保存一次
  504. await this.$refs.balanceTableRef.saveChildSheet()
  505. // 重新获取当前子表的数据
  506. this.$refs.balanceTableRef.getSheetDetail('refresh')
  507. },
  508. backHandle(){
  509. this.$router.back()
  510. },
  511. /* 获取分类 */
  512. getClassify() {
  513. sheetInterface.excelClassifyOne({ Source: 5 }).then(res => {
  514. if (res.Ret !== 200) return
  515. this.classifyArr = res.Data.AllNodes || [];
  516. })
  517. },
  518. // 递归处理数组
  519. deleteUserEmpty(arr) {
  520. arr.length && arr.forEach(item => {
  521. item.Children && item.Children.length && this.deleteUserEmpty(item.Children)
  522. if (!item.Children || !item.Children.length) {
  523. delete item.Children
  524. }
  525. })
  526. },
  527. getSystemUserList() {
  528. departInterence.getSystemUser({
  529. KeyWord: ''
  530. }).then(res => {
  531. if (res.Ret === 200) {
  532. this.deleteUserEmpty(res.Data || [])
  533. this.userList = res.Data || []
  534. }
  535. })
  536. },
  537. //更新编辑状态
  538. markFinishStatus(){
  539. if(!this.sheetId) return
  540. sheetInterface.markSheetEditStatus({ExcelInfoId:Number(this.sheetId),Status:2}).then(res=>{
  541. if(res.Ret != 200) return
  542. })
  543. },
  544. isSheetBtnShow(type){
  545. return this.permissionBtn.isShowBtn('etaTablePermission',`etaTable_customize_balance_${type}`)
  546. }
  547. },
  548. }
  549. </script>
  550. <style lang="scss">
  551. .sheet-classify-cascader .el-input {
  552. width: 100%;
  553. }
  554. </style>
  555. <style scoped lang="scss">
  556. * {
  557. box-sizing: border-box;
  558. }
  559. .balance-sheet-detail-wrap {
  560. min-width: 1070px;
  561. min-height: calc(100vh - 120px);
  562. position: relative;
  563. .no-auth-box{
  564. position: absolute;
  565. z-index: 99;
  566. left: 0;
  567. right: 0;
  568. bottom: 0;
  569. top: 0;
  570. background-color: #F2F6FA;
  571. }
  572. .wrap-top {
  573. display: flex;
  574. justify-content: space-between;
  575. align-items: center;
  576. margin-bottom: 20px;
  577. padding: 20px;
  578. background: #fff;
  579. border: 1px solid #ececec;
  580. border-radius: 4px;
  581. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
  582. display: flex;
  583. z-index: 1;
  584. .form-ul {
  585. // flex: 1;
  586. display: flex;
  587. align-items: center;
  588. gap: 0 5px;
  589. li {
  590. &:first-child {
  591. padding-top: 0;
  592. }
  593. }
  594. }
  595. }
  596. }
  597. </style>