audit-archives-form.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. <template>
  2. <audit-form-top-banner
  3. ref="banner"
  4. :handel-submit-form="alreadyflag ? submitForm : null"
  5. :handel-save-form="filingflag ? saveForm : null"
  6. :handel-rollback="stayflag ? handelRollback : null"
  7. @handelRollback="handelRollback"
  8. @handelSubmitForm="submitForm"
  9. @handelSaveForm="saveForm"
  10. >
  11. <sd-detail-form
  12. ref="docform"
  13. form-id="iamArchivesMaintain"
  14. page-id="audit/archives/iamArchivesMaintain"
  15. :record-id="this.$route.query.record ? parseInt(this.$route.query.record) : null"
  16. :class="$style.form"
  17. :read-only="readOnly"
  18. @close="close(true)"
  19. @saved="saved"
  20. >
  21. <template v-slot="{ model, fields }">
  22. <table>
  23. <tr>
  24. <td style="border:none;padding-left:5px">
  25. <audit-advanced-group
  26. :expand="templateExpand"
  27. :expand-str="'templateExpand'"
  28. :group-label="'基本信息'"
  29. tablestyle="''"
  30. @changedClick="changedClick"
  31. ></audit-advanced-group>
  32. </td>
  33. </tr>
  34. </table>
  35. <table v-show="templateExpand">
  36. <!--自动生成 系统档案-->
  37. <tr v-if="model.archivesType === 'SYSTEM_FILE'">
  38. <!-- 项目名称 -->
  39. <td class="ant-form-item-label ant-form-item-label"
  40. ><label title="项目名称"> 项目名称 </label></td
  41. >
  42. <sd-form-item-td name="projectName" :label="null">
  43. <span>{{ model.projectName }}</span>
  44. </sd-form-item-td>
  45. <!-- 档案编号 -->
  46. <td class="ant-form-item-label ant-form-item-label"
  47. ><label title="档案编号"> 档案编号 </label></td
  48. >
  49. <sd-form-item-td name="archivesCode" :label="null">
  50. <span>{{ model.archivesCode }}</span>
  51. </sd-form-item-td>
  52. </tr>
  53. <tr v-if="model.archivesType === 'SYSTEM_FILE'">
  54. <!-- 档案类型 -->
  55. <td class="ant-form-item-label ant-form-item-label"
  56. ><label title="档案类型"> 档案类型 </label></td
  57. >
  58. <sd-form-item-td name="archivesType" :label="null">
  59. <span>系统档案</span>
  60. </sd-form-item-td>
  61. <!-- 项目所属年度 -->
  62. <td class="ant-form-item-label ant-form-item-label"
  63. ><label title="项目所属年度"> 项目所属年度 </label></td
  64. >
  65. <sd-form-item-td name="planYear" :label="null">
  66. <span>{{ model.planYear }}</span>
  67. </sd-form-item-td>
  68. </tr>
  69. <!--自动生成 手动生成档案-->
  70. <tr v-if="model.archivesType !== 'SYSTEM_FILE'">
  71. <!-- 项目名称 -->
  72. <sd-form-item-td name="projectName" />
  73. <!-- 档案编号 -->
  74. <!-- <sd-form-item-td name="archivesCode" /> -->
  75. <sd-form-item-td name="archivesCode">
  76. <a-form-model-item
  77. :rules="[
  78. {
  79. validator: validator,
  80. trigger: ['change', 'blur'],
  81. },
  82. ]"
  83. prop="archivesCode"
  84. >
  85. <a-input v-model="model.archivesCode"></a-input>
  86. </a-form-model-item>
  87. </sd-form-item-td>
  88. </tr>
  89. <tr v-if="model.archivesType !== 'SYSTEM_FILE'">
  90. <!-- 档案类型 -->
  91. <sd-form-item-td name="archivesType">
  92. <a-select v-model="model.archivesType">
  93. <a-select-option :value="'HISTORY_FILE'">
  94. 历史档案
  95. </a-select-option>
  96. <a-select-option :value="'OFFLINE_FILE'">
  97. 线下档案
  98. </a-select-option>
  99. </a-select>
  100. </sd-form-item-td>
  101. <!-- 项目所属年度 -->
  102. <sd-form-item-td name="planYear">
  103. <a-date-picker
  104. v-model="model.planYear"
  105. mode="year"
  106. picker="YYYY"
  107. format="YYYY"
  108. :allow-clear="false"
  109. placeholder="选择年度"
  110. :input-read-only="true"
  111. :value="year"
  112. :open="endOpen"
  113. @panelChange="yearChange"
  114. @openChange="handleEndOpenChange"
  115. ></a-date-picker>
  116. </sd-form-item-td>
  117. </tr>
  118. <tr>
  119. <!-- 简要描述 -->
  120. <sd-form-item-td name="brieflyDesc" :colspan="3">
  121. <a-textarea v-model="model.brieflyDesc" :rows="3" />
  122. </sd-form-item-td>
  123. </tr>
  124. <tr v-if="model.archivesType === 'SYSTEM_FILE'">
  125. <td class="ant-form-item-label ant-form-item-label"
  126. ><label title="案卷状态"> 案卷状态 </label></td
  127. >
  128. <sd-form-item-td name="fileState" :label="null">
  129. <span>
  130. {{ getDictValue(fields.fileState.attr.selectListItem, model.fileState) }}
  131. </span>
  132. </sd-form-item-td>
  133. </tr>
  134. <tr v-else>
  135. <sd-form-item-td name="fileState" :colspan="3" />
  136. </tr>
  137. <tr>
  138. <!-- 最后修改时间 -->
  139. <sd-form-item-td name="lastModifiedTime" />
  140. <!-- 归档日期 -->
  141. <sd-form-item-td name="filingDate" />
  142. </tr>
  143. <tr>
  144. <!-- 编制人员 -->
  145. <sd-form-item-td name="creatorName" />
  146. <!-- 编制日期 -->
  147. <sd-form-item-td v-if="initparams(model)" name="creationTime" />
  148. </tr>
  149. <tr>
  150. <!-- 所属单位 -->
  151. <sd-form-item-td name="belongDeptMember" :colspan="3" />
  152. <!-- ID -->
  153. <sd-form-item-td :hidden="true" name="id" :colspan="3" />
  154. </tr>
  155. </table>
  156. <table>
  157. <tr>
  158. <td style="border:none;padding-left:5px">
  159. <audit-advanced-group
  160. :expand="expandA"
  161. :expand-str="'expandA'"
  162. :group-label="'案卷信息'"
  163. tablestyle="''"
  164. @changedClick="changedClick"
  165. ></audit-advanced-group>
  166. </td>
  167. </tr>
  168. </table>
  169. <table v-show="expandA">
  170. <AuditArchivesTree
  171. ref="tree1"
  172. :status="fileState"
  173. :archives-type="archivesType"
  174. :fromflag="fromFlag"
  175. :userinfoname="userInfoName"
  176. :columns="childAJColumns"
  177. :actions="childAJActions"
  178. form-id="iamDossierData"
  179. page-id="audit/archives/iamDossierData"
  180. :treeparams="{
  181. configId: '22',
  182. }"
  183. :change="treechange"
  184. :record-id="recordId"
  185. >
  186. </AuditArchivesTree>
  187. </table>
  188. </template>
  189. </sd-detail-form>
  190. </audit-form-top-banner>
  191. </template>
  192. <script>
  193. import { getUserInfo } from '@/common/store-mixin'
  194. import debounce from 'lodash.debounce'
  195. import axios from '@/common/services/axios-instance'
  196. import { Modal, Message } from 'ant-design-vue'
  197. import TableColumnTypes from '@/common/services/table-column-types'
  198. import TableActionTypes from '@/common/services/table-action-types'
  199. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  200. import auditFormTopBanner from '../../components/audit-form-top-banner'
  201. import auditAdvancedGroup from '../../components/audit-advanced-group.vue'
  202. import auditAdvancedGroupMixins from '../../components/audit-advanced-group-mixins'
  203. import AuditArchivesTree from './audit-archives-tree'
  204. import components from './_import-components/audit-archives-form-import'
  205. export default {
  206. name: 'AuditArchivesForm',
  207. metaInfo: {
  208. title: '档案管理',
  209. },
  210. components: {
  211. ...components,
  212. auditAdvancedGroup,
  213. auditFormTopBanner,
  214. AuditArchivesTree,
  215. },
  216. mixins: [auditAdvancedGroupMixins],
  217. data() {
  218. return {
  219. isSave: false, // 是否保存
  220. endOpen: false,
  221. year: null,
  222. alreadyflag: true,
  223. filingflag: false,
  224. stayflag: false,
  225. treeId: '',
  226. expandA: true,
  227. saveFlag: true,
  228. templateExpand: true,
  229. readOnly: false,
  230. flag: true,
  231. fileState: '',
  232. archivesType: '',
  233. fromFlag: '',
  234. userInfoName: '',
  235. recordId: '',
  236. childAJColumns: [
  237. {
  238. title: '序号',
  239. dataIndex: 'sortNum',
  240. width: '80px',
  241. customRender: (text, record, index) => `${index + 1}`,
  242. },
  243. { dataIndex: 'id', sdHidden: true },
  244. {
  245. title: '文件名称',
  246. dataIndex: 'docTitle',
  247. scopedSlots: { customRender: 'islink' },
  248. width: '50%',
  249. },
  250. {
  251. title: '编制人员',
  252. dataIndex: 'creatorName',
  253. },
  254. {
  255. title: '编制日期',
  256. dataIndex: 'creationTime',
  257. defaultSortOrder: 'descend', // 没有点击任何排序列时,默认的排序列
  258. sdRender: TableColumnTypes.date,
  259. },
  260. ],
  261. customaction: {
  262. label: '新建',
  263. id: 'new',
  264. permission: 'create',
  265. type: TableActionTypes.primary,
  266. callback: () => {
  267. if (this.treeId != null && this.treeId !== undefined && this.treeId !== '') {
  268. // const archivesId = this.$route.query.record
  269. const archivesId = this.recordId
  270. const parentId = this.treeId
  271. const fromFlag = this.$route.query.fromFlag
  272. let fileState = this.fileState
  273. if (fileState === undefined) {
  274. fileState = this.$refs.docform.getFieldValue('fileState')
  275. this.fileState = fileState
  276. }
  277. const userInfo = getUserInfo()
  278. const url =
  279. '/audit-dossier-form?archivesId=' +
  280. archivesId +
  281. '&parentId=' +
  282. parentId +
  283. '&fileState=' +
  284. fileState +
  285. '&fromFlag=' +
  286. fromFlag +
  287. '&userInfoName=' +
  288. userInfo.name // 新页面要打开的路由地址
  289. crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
  290. if (refreshFlag) {
  291. // 这里写或者调刷新的方法
  292. this.refresh()
  293. }
  294. })
  295. } else {
  296. Modal.confirm({
  297. title: '提示',
  298. content: '请先选择案卷信息分类。',
  299. okText: '确定',
  300. okType: 'danger',
  301. })
  302. }
  303. },
  304. },
  305. deletaction: {
  306. label: '删除',
  307. id: 'delete',
  308. type: TableActionTypes.oa.delete, // 删除按钮,不需要回调,会自动处理
  309. },
  310. flagcreat: true,
  311. childAJActions: [
  312. {
  313. label: '删除',
  314. id: 'delete',
  315. type: TableActionTypes.oa.delete, // 删除按钮,不需要回调,会自动处理
  316. },
  317. ],
  318. }
  319. },
  320. computed: {
  321. // 计算随机key
  322. randomId() {
  323. let randomNum = Math.random()
  324. while (randomNum === 0) {
  325. randomNum = Math.random()
  326. }
  327. const time = new Date().getTime()
  328. return time + Math.ceil(randomNum * 1000000000)
  329. },
  330. },
  331. mounted() {
  332. // 监听关闭事件,关闭时如果没有保存操作且没有id,则直接删除所有子表
  333. window.addEventListener('beforeunload', (e) => {
  334. this.beforeunloadHandler(e)
  335. })
  336. },
  337. created() {
  338. if (this.$route.query.record) {
  339. this.recordId = this.$route.query.record
  340. this.fromFlag = this.$route.query.fromFlag
  341. } else {
  342. // 使用随机ID
  343. this.recordId = this.randomId
  344. }
  345. },
  346. methods: {
  347. // 获取字典值
  348. getDictValue(list, val) {
  349. return list.find((item) => {
  350. return item.value.trim() === (val + '').trim()
  351. })?.label
  352. },
  353. // 关闭窗口监听
  354. beforeunloadHandler(e) {
  355. if (!this.isSave && !this.$refs.flow.getFieldValue('id')) {
  356. // 此处需要调用接口删除所有档案关联的临时ID数据,否则会有脏数据
  357. axios({
  358. url: 'api/xcoa-mobile/v1/iamarchivesmaintain/deletedArchives?id=' + this.recordId,
  359. method: 'post',
  360. })
  361. }
  362. },
  363. validator(rule, value, callback) {
  364. value = encodeURIComponent(value)
  365. const id = this.$route.query.record || ''
  366. debounce(() => {
  367. axios
  368. .get(
  369. `api/xcoa-mobile/v1/iamarchivesmaintain/findArchivesCode?archivesCode=${value}&id=` + id
  370. )
  371. .then((res) => {
  372. if (res?.data === true) {
  373. callback()
  374. } else {
  375. callback('已存在,不允许重复')
  376. }
  377. })
  378. }, 500)()
  379. },
  380. yearChange(value) {
  381. this.year = value
  382. this.$refs.docform.setFieldValue('planYear', value.format('YYYY'))
  383. this.$refs.docform.validateField('planYear').then((res) => {
  384. console.log(res)
  385. })
  386. if (document.getElementsByClassName('ant-calendar-picker-container').length > 0) {
  387. document.getElementsByClassName('ant-calendar-picker-container')[0].style.display = 'none'
  388. }
  389. },
  390. handleEndOpenChange(open) {
  391. this.endOpen = open
  392. },
  393. initparams(model) {
  394. if (this.flagcreat) {
  395. this.flagcreat = false
  396. this.fileState = model.fileState
  397. const fromFlag = this.$route.query.fromFlag
  398. const userInfo = getUserInfo()
  399. if (fromFlag === 'projectList') {
  400. this.stayflag = false
  401. this.filingflag = true
  402. } else if (model.creatorName === userInfo.name) {
  403. if (this.fileState === 'FILING' || model.fileState === undefined) {
  404. this.filingflag = true
  405. } else if (this.fileState === 'ALREADY_FILE') {
  406. this.alreadyflag = false
  407. this.stayflag = true
  408. this.childAJActions = []
  409. this.readOnly = true
  410. } else {
  411. this.alreadyflag = true
  412. this.stayflag = true
  413. this.childAJActions = []
  414. this.readOnly = true
  415. }
  416. } else if (this.flag) {
  417. if (model.fileState !== undefined) {
  418. this.flag = false
  419. axios({
  420. url: 'api/xcoa-mobile/v1/iamarchivesmaintain/findHasPermission',
  421. method: 'post',
  422. }).then((res) => {
  423. if (res.data === true) {
  424. if (this.fileState === 'STAY_FILE') {
  425. this.stayflag = true
  426. this.readOnly = true
  427. this.childAJActions = []
  428. }
  429. if (this.fileState === 'FILING') {
  430. this.filingflag = true
  431. }
  432. if (this.fileState === 'ALREADY_FILE') {
  433. this.alreadyflag = false
  434. this.stayflag = true
  435. this.childAJActions = []
  436. this.readOnly = true
  437. }
  438. } else {
  439. this.alreadyflag = false
  440. this.readOnly = true
  441. this.childAJActions = []
  442. }
  443. })
  444. }
  445. }
  446. this.year = model.planYear
  447. }
  448. this.archivesType = model.archivesType
  449. return true
  450. },
  451. refresh() {
  452. return this.$refs.tree1.$refs.dataTable.refresh(true)
  453. },
  454. close(flag) {
  455. crossWindowWatcher.notifyChange(this.$route.fullPath, flag)
  456. window.close()
  457. },
  458. // 提交
  459. submitForm() {
  460. this.$refs.docform.validateFields().then(() => {
  461. this.$refs.docform.setFieldValue('randomId', this.recordId)
  462. const fileState = this.$refs.docform.getFieldValue('fileState')
  463. const archivesType = this.$refs.docform.getFieldValue('archivesType')
  464. // 自创档案 立卷————>已归档
  465. if (archivesType !== 'SYSTEM_FILE') {
  466. this.$refs.docform.setFieldValue('fileState', 'ALREADY_FILE')
  467. } else {
  468. // 自创档案 立卷————>待归档————>已归档
  469. // 立卷变待归档
  470. if (fileState === 'FILING') {
  471. this.$refs.docform.setFieldValue('fileState', 'STAY_FILE')
  472. }
  473. // 待归档变已归档
  474. if (fileState === 'STAY_FILE') {
  475. this.$refs.docform.setFieldValue('fileState', 'ALREADY_FILE')
  476. }
  477. }
  478. this.$refs.docform.save().then((res) => {
  479. const beanId = res.data.pageFormData.beanId
  480. if (window.location.href.indexOf('record') < 0) {
  481. this.$router.replace(`?record=` + beanId)
  482. }
  483. })
  484. Message.success('提交成功').then((res) => {
  485. this.isSave = true
  486. this.$refs.docform.saveBtnClick()
  487. })
  488. })
  489. },
  490. // 保存
  491. saveForm() {
  492. this.$refs.docform.validateFields().then(() => {
  493. this.$refs.docform.setFieldValue('randomId', this.recordId)
  494. this.$refs.docform.save().then((res) => {
  495. const beanId = res.data.pageFormData.beanId
  496. if (window.location.href.indexOf('record') < 0) {
  497. this.$router.replace(`?record=` + beanId)
  498. }
  499. this.isSave = true
  500. Message.success('保存成功')
  501. })
  502. })
  503. },
  504. saved() {
  505. this.close(true)
  506. },
  507. handelRollback() {
  508. this.$refs.docform.validateFields().then(() => {
  509. const fileState = this.$refs.docform.getFieldValue('fileState')
  510. // 已归档变待归档
  511. if (fileState === 'ALREADY_FILE') {
  512. this.$refs.docform.setFieldValue('fileState', 'STAY_FILE')
  513. }
  514. // 待归档变立卷
  515. if (fileState === 'STAY_FILE') {
  516. this.$refs.docform.setFieldValue('fileState', 'FILING')
  517. }
  518. })
  519. this.$refs.docform.saveBtnClick()
  520. },
  521. treechange(unableselect, id) {
  522. const userInfo = getUserInfo()
  523. const creatorName = this.$refs.docform.getFieldValue('creatorName')
  524. const fileState = this.$refs.docform.getFieldValue('fileState')
  525. this.treeId = id
  526. this.unableselect = unableselect
  527. this.childAJActions = []
  528. this.childAJActions.push(this.deletaction)
  529. const fromFlag = this.$route.query.fromFlag
  530. // const archivesId = this.$route.query.record
  531. // 用随机ID
  532. const archivesId = this.recordId
  533. const archivesType = this.$refs.docform.getFieldValue('archivesType')
  534. if (this.unableselect !== true && fromFlag === 'projectList') {
  535. this.childAJActions.push(this.customaction)
  536. } else if (this.unableselect !== true && archivesId === undefined) {
  537. Modal.confirm({
  538. title: '提示',
  539. content: '请先保存案卷管理基本信息',
  540. okText: '确定',
  541. okType: 'danger',
  542. })
  543. } else if (archivesType === 'SYSTEM_FILE') {
  544. if (creatorName === userInfo.name && (fileState !== 'FILING' || unableselect === true)) {
  545. this.childAJActions = []
  546. } else {
  547. this.childAJActions.push(this.customaction)
  548. }
  549. } else {
  550. axios({
  551. url: 'api/xcoa-mobile/v1/iamarchivesmaintain/findHasPermission',
  552. method: 'post',
  553. }).then((res) => {
  554. if (res.data !== true) {
  555. this.childAJActions = []
  556. } else if (fileState !== 'FILING' || unableselect === true) {
  557. if (fileState === 'STAY_FILE' || fileState === 'ALREADY_FILE') {
  558. this.alreadyflag = false
  559. }
  560. this.childAJActions = []
  561. } else {
  562. this.childAJActions.push(this.customaction)
  563. }
  564. })
  565. }
  566. },
  567. },
  568. }
  569. </script>
  570. <style module lang="scss">
  571. @import '@/webflow/sd-flow-form.scss';
  572. </style>