阅行客电子档案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1087 lines
39 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="preview-content right-preview">
  3. <el-form ref="addOrUpdateForm" :model="addOrUpdateForm" :rules="rules" :validate-on-rule-change="false" label-width="125px">
  4. <el-row :gutter="4" style="padding:0 20px">
  5. <draggable v-bind="{draggable:'.drag-item',animation:500}" :disabled="!isDraggable" @update="datadragEnd">
  6. <el-col v-for="(item,index) in formPreviewData" v-show="item.fieldName !== 'barcode' && item.fieldName !== 'is_entity'" :key="index" :class="['drag-item',item.fieldName === 'barcode'? 'barcode-input':'']" :span="item.isLine || item.fieldName === 'barcode' ? 24 : 12">
  7. <el-form-item :label="item.fieldCnName" :prop="item.fieldName">
  8. <!-- select :load-options="loadOptions"-->
  9. <treeselect
  10. v-if="item.isInputClass === 'select'"
  11. v-model="addOrUpdateForm[item.fieldName]"
  12. :options="item.options"
  13. :normalizer=" isTableType === 1 ? normalizerFonds : (isTableType === 2 ? normalizerClassify : normalizer)"
  14. :clearable="false"
  15. placeholder=""
  16. flat
  17. :style="{ width: item.editLength+'px'}"
  18. :disabled="isDisabled"
  19. :validate-event="!isDisabled"
  20. no-options-text="无数据"
  21. @select="selectTree"
  22. @open="openTree(item)"
  23. >
  24. <div slot="value-label" slot-scope="{ node }">{{ getAutoNameUnknown(node.label) }}</div>
  25. </treeselect>
  26. <!-- text / number / textarea / popover -->
  27. <!-- :validate-event="isDisabled" -->
  28. <el-input
  29. v-if="item.isInputClass !== 'select' && item.isInputClass !== 'date' && item.fieldName !== 'barcode' "
  30. v-model="addOrUpdateForm[item.fieldName]"
  31. :type="item.isInputClass === 'popover'? 'text' : item.isInputClass"
  32. :rows="item.isInputClass === 'textarea' ? 3 : ''"
  33. :class="{'input-popover':(item.isInputClass === 'popover')}"
  34. :style="{ width: item.editLength+'px'}"
  35. :disabled="isDisabled || (item.fieldName === 'archival_category_code')"
  36. :validate-event="!isDisabled"
  37. @keyup.enter.native="isRepeatHandle(item)"
  38. @input="autoAddZero(item.isFilling, item.fieldName, addOrUpdateForm[item.fieldName], item.fillingDigit)"
  39. @blur="isRepeatHandle(item)"
  40. >
  41. <i v-if="item.isInputClass === 'popover'" slot="suffix" class="el-input__icon iconfont icon-gengduo1" @click="handleCurrentFieldName(item)" />
  42. </el-input>
  43. <!-- date -->
  44. <el-date-picker v-if="item.isInputClass === 'date'" v-model="addOrUpdateForm[item.fieldName]" type="date" align="right" format="yyyy-MM-dd" placeholder="" :clearable="false" :style="{ width: item.editLength+'px'}" :disabled="isDisabled" :validate-event="!isDisabled" />
  45. </el-form-item>
  46. </el-col>
  47. </draggable>
  48. </el-row>
  49. <el-row v-if="!isHasCode && isDesFormType !== 'prearchiveLibrary' && isDesFormType !== 'mergeFile'" class="preview-form-bottom">
  50. <el-col v-for="(item,index) in formPreviewData.slice(formPreviewData.length-1,formPreviewData.length)" :key="'barcode'+index">
  51. <el-form-item :label="item.fieldCnName" :prop="item.fieldName">
  52. <el-input v-model="addOrUpdateForm[item.fieldName]" type="text" style="width: 510px" :disabled="isDisabled" :validate-event="!isDisabled" @keyup.enter.native="isRepeatHandle(item)" @blur="isRepeatHandle(item)" />
  53. </el-form-item>
  54. </el-col>
  55. </el-row>
  56. <el-row v-if="isDesFormType === 'prearchiveLibrary'" class="preview-form-bottom prearch-bottom">
  57. <el-col>
  58. <el-form-item label="电子原件" prop="fileOriginal" class="prearch-upload" :rules="[{ required: true, message: '请上传原文',trigger: 'blur' }]">
  59. <el-input
  60. v-model="addOrUpdateForm['fileOriginal']"
  61. type="text"
  62. style="width: 446px"
  63. readonly
  64. />
  65. <div class="upload-btn">
  66. <input id="upFile" type="file" name="upFile" @change="changeFile($event)">
  67. <el-button size="small" type="primary"><i class="iconfont icon-shangchuan" />上传</el-button>
  68. </div>
  69. </el-form-item>
  70. </el-col>
  71. </el-row>
  72. <el-row v-if="isDesFormType !== 'prearchiveLibrary' && isDesFormType !== 'mergeFile'" class="preview-form-bottom prearch-bottom">
  73. <el-col v-for="(item,index) in formPreviewData" :key="index">
  74. <el-form-item v-if="item.fieldName === 'is_entity'" label="有无实体" :prop="item.fieldName" :rules="[{ required: true, message: '请选择',trigger: 'change' }]" class="pbysical-style">
  75. <el-radio-group v-model="addOrUpdateForm[item.fieldName]">
  76. <el-radio :label="1"></el-radio>
  77. <el-radio :label="0"></el-radio>
  78. </el-radio-group>
  79. </el-form-item>
  80. </el-col>
  81. </el-row>
  82. </el-form>
  83. <!-- 弹框形式的内容展示 -->
  84. <el-dialog class="edit-form-dialog" :append-to-body="true" :visible="popoverVisible" :before-close="handleClose" :close-on-click-modal="false" :title="tableTitle">
  85. <span class="dialog-right-top" />
  86. <span class="dialog-left-bottom" />
  87. <div class="setting-dialog">
  88. <el-table ref="popoverTable" :data="popoverTableData" highlight-current-row row-key="dictionaryCode" :tree-props="{children: 'childDictionarys', hasChildren: 'hasChildren'}" height="600" style="width: 100%;" @selection-change="handleSelectionChange" @row-click="clickRowHandler">
  89. <el-table-column :selectable="checkboxT" type="selection" width="55" />
  90. <el-table-column prop="dictionaryName" label="字典名称" show-overflow-tooltip />
  91. <el-table-column prop="dictionaryCode" label="字典代码" />
  92. <el-table-column prop="dictionaryRemarks" label="内容说明" show-overflow-tooltip />
  93. </el-table>
  94. </div>
  95. </el-dialog>
  96. <el-dialog class="edit-form-dialog" :append-to-body="true" :visible="popoverFondsVisible" :before-close="handleClose" :close-on-click-modal="false" :title="tableTitle">
  97. <span class="dialog-right-top" />
  98. <span class="dialog-left-bottom" />
  99. <div class="setting-dialog">
  100. <el-table ref="popoverTable" :data="popoverTableDataFonds" highlight-current-row row-key="id" :tree-props="{children: 'childMenus', hasChildren: 'hasChildren'}" height="600" style="width: 100%; he" @selection-change="handleSelectionChange" @row-click="clickRowHandler">
  101. <el-table-column type="selection" width="55" show-overflow-tooltip />
  102. <el-table-column prop="fondsNo" label="全宗号" />
  103. <el-table-column prop="fondsName" label="全宗名称" show-overflow-tooltip />
  104. <el-table-column prop="fondsOrders" label="排序" width="60" />
  105. </el-table>
  106. </div>
  107. </el-dialog>
  108. <el-dialog class="edit-form-dialog" :append-to-body="true" :visible="popoverClassifyVisible" :before-close="handleClose" :close-on-click-modal="false" :title="tableTitle">
  109. <span class="dialog-right-top" />
  110. <span class="dialog-left-bottom" />
  111. <div class="setting-dialog">
  112. <el-table ref="popoverTable" :data="popoverTableDataClassify" highlight-current-row row-key="id" :tree-props="{children: 'childArchivesClass', hasChildren: 'hasChildren'}" height="600" style="width: 100%;" @selection-change="handleSelectionChange" @row-click="clickRowHandler">
  113. <el-table-column type="selection" width="55" />
  114. <el-table-column label="分类名称" prop="name" width="130" show-overflow-tooltip />
  115. <el-table-column label="分类编号" prop="code" />
  116. <el-table-column label="排序" prop="classSeq" />
  117. <el-table-column label="所属门类" prop="categoryName" show-overflow-tooltip />
  118. </el-table>
  119. </div>
  120. </el-dialog>
  121. </div>
  122. </template>
  123. <script>
  124. import { crud } from '@crud/crud'
  125. import { FetchDoeditIsRepeat } from '@/api/archivesManage/archivesList'
  126. import { collectAdd, collectEdit } from '@/api/collect/collect'
  127. import { prearchEdit, FetchMergeToFile, FetchReDoeditIsRepeat } from '@/api/prearchiveLibrary/prearchiveLibrary'
  128. import { getNoFormatField } from '@/api/system/category/fileNoFormat'
  129. import draggable from 'vuedraggable'
  130. import Treeselect from '@riophae/vue-treeselect'
  131. import '@riophae/vue-treeselect/dist/vue-treeselect.css'
  132. import { FetchSonDictionaryList, FetchDictionaryTree } from '@/api/system/dict'
  133. import { FetchFondsAll } from '@/api/system/fonds'
  134. import { FetchArchivesClassTree, FetchSonArchivesClass } from '@/api/system/archivesClass'
  135. import { parseTime, getCurrentTime } from '@/utils/index'
  136. import { reDocumentUpload } from '@/utils/upload'
  137. import { mapGetters } from 'vuex'
  138. export default {
  139. name: 'PreviewForm',
  140. components: { draggable, Treeselect },
  141. mixins: [crud()],
  142. inject: ['parentsData'],
  143. props: {
  144. isDisabled: {
  145. type: Boolean,
  146. required: true
  147. },
  148. formPreviewData: {
  149. type: Array,
  150. required: true
  151. },
  152. selectedCategory: {
  153. type: Object,
  154. default: function() {
  155. return {}
  156. }
  157. },
  158. selectedDocument: {
  159. type: Object,
  160. default: function() {
  161. return {}
  162. }
  163. },
  164. arcId: {
  165. type: String,
  166. default: ''
  167. },
  168. isHasCode: {
  169. type: Boolean,
  170. required: true
  171. },
  172. isDraggable: {
  173. type: Boolean,
  174. default: false
  175. },
  176. isDesFormType: {
  177. type: String,
  178. default: ''
  179. },
  180. collectLevel: {
  181. type: Number,
  182. default: 1
  183. },
  184. isTitleType: {
  185. type: Number,
  186. default: 2
  187. }
  188. },
  189. data() {
  190. return {
  191. fileOriginal: null,
  192. addOrUpdateForm: {
  193. },
  194. rules: {
  195. },
  196. isTableType: 1,
  197. tableTitle: '字典列表',
  198. popoverTableData: [], // popover - popoverTableData
  199. popoverVisible: false, // popover - visible
  200. popoverTableDataClassify: [],
  201. popoverClassifyVisible: false,
  202. popoverTableDataFonds: [],
  203. popoverFondsVisible: false,
  204. currentFieldName: null, // popover 当前fieldName
  205. treeCurrentFiled: null,
  206. categoryId: null,
  207. result: null,
  208. autoMatic: null,
  209. file: null, // 附件 change
  210. fileNames: '', // 附件 - name
  211. formatType: '', // 附件 - type
  212. postfix: '', // 附件 - 文件后缀
  213. fileSize: '', // 附件 - 大小
  214. filePath: '', // 附件 - path
  215. px: '', // 附件 - 分辨率
  216. nowDate: '', // 当前时间
  217. fileJsonString: null,
  218. mergeFileArcIds: null,
  219. mergeFileCategory: null,
  220. archivesType: null,
  221. activeIndex: null
  222. }
  223. },
  224. computed: {
  225. ...mapGetters([
  226. 'baseApi',
  227. 'user'
  228. ])
  229. },
  230. watch: {
  231. selectedCategory: function(newValue, oldValue) {
  232. },
  233. selectedDocument: function(newValue, oldValue) {
  234. },
  235. arcId: function(newValue, oldValue) {
  236. },
  237. isDesFormType: function(newValue, oldValue) {
  238. },
  239. formPreviewData: function() {
  240. this.editFormRow()
  241. // 区分 门类著录项 和 档案管理
  242. if (this.isDesFormType === 'category') {
  243. this.FetchNoFormatField(this.selectedCategory.id)
  244. }
  245. }
  246. },
  247. created() {
  248. this.editFormRow()
  249. },
  250. mounted() {
  251. },
  252. methods: {
  253. checkboxT(row, rowIndex) {
  254. return row.level ? row.level === 3 : true
  255. },
  256. normalizer(node) {
  257. if ((node.childDictionarys && !node.childDictionarys.length) || node.childDictionarys === null) {
  258. delete node.childDictionarys
  259. }
  260. return {
  261. id: node.dictionaryName,
  262. label: node.dictionaryName,
  263. children: node.childDictionarys,
  264. isDisabled: node.level && node.level !== 3
  265. }
  266. },
  267. normalizerClassify(node) {
  268. if ((node.childArchivesClass && !node.childArchivesClass.length) || node.childArchivesClass === null) {
  269. delete node.childArchivesClass
  270. }
  271. return {
  272. id: node.code,
  273. label: node.name,
  274. children: node.childArchivesClass
  275. }
  276. },
  277. normalizerFonds(node) {
  278. if (node.childMenus == null || node.childMenus === 'null') {
  279. delete node.childMenus
  280. }
  281. return {
  282. id: node.fondsNo,
  283. label: node.fondsName,
  284. children: node.childMenus
  285. }
  286. },
  287. // 处理vue-treeSelect回显出现unknown问题
  288. getAutoNameUnknown(name) {
  289. if (name.lastIndexOf('unknown') > -1) {
  290. // 当treeselect翻译不了值时,name中有id,截取id,去调接口或者字典查询出名字
  291. return name.split('(')[0]
  292. } else {
  293. return name
  294. }
  295. },
  296. getNode(list, dictionaryName) {
  297. let data;
  298. (list || []).map(item => {
  299. if (item.dictionaryName === dictionaryName) {
  300. data = [item]
  301. } else {
  302. const child = this.getNode(item.childMenus, dictionaryName)
  303. if (child) {
  304. data = child
  305. }
  306. }
  307. })
  308. return data
  309. },
  310. getFondsNode(list, fondsNo) {
  311. let data;
  312. (list || []).map(item => {
  313. if (item.fondsNo === fondsNo) {
  314. data = [item]
  315. } else {
  316. const child = this.getFondsNode(item.childMenus, fondsNo)
  317. if (child) {
  318. data = child
  319. }
  320. }
  321. })
  322. return data
  323. },
  324. getClassfiyNode(list, code) {
  325. let data;
  326. (list || []).map(item => {
  327. if (item.code === code) {
  328. data = [item]
  329. } else {
  330. const child = this.getClassfiyNode(item.childArchivesClass, code)
  331. if (child) {
  332. data = child
  333. }
  334. }
  335. })
  336. return data
  337. },
  338. // 自动生成
  339. handleAuto() {
  340. let string = ''
  341. const getAutoFiledVal = []
  342. this.autoMatic.forEach(async val => {
  343. if (!this.addOrUpdateForm[val.fieldName]) {
  344. string += ''
  345. } else {
  346. const fieldInfo = this.formPreviewData.find(element => element.fieldName === val.fieldName)
  347. if (fieldInfo.isInputClass === 'select' || fieldInfo.isInputClass === 'popover') {
  348. if (fieldInfo.mateData === 3) {
  349. await FetchSonDictionaryList({ 'pid': fieldInfo.dictionaryId.id }).then(res => {
  350. const option = this.getNode(res, this.addOrUpdateForm[val.fieldName])
  351. if (option) {
  352. const obj = {}
  353. obj.name = val.fieldName
  354. obj.val = option[0].dictionaryCode + val.connector
  355. obj.sequence = val.sequence
  356. getAutoFiledVal.push(obj)
  357. }
  358. })
  359. }
  360. if (fieldInfo.mateData === 1) {
  361. await FetchFondsAll().then(res => {
  362. const option = this.getFondsNode(res, this.addOrUpdateForm[val.fieldName])
  363. if (option) {
  364. const obj = {}
  365. obj.name = val.fieldName
  366. obj.val = option[0].fondsNo + val.connector
  367. obj.sequence = val.sequence
  368. getAutoFiledVal.push(obj)
  369. }
  370. })
  371. }
  372. if (fieldInfo.mateData === 2) {
  373. let categoryId
  374. if (this.isDesFormType !== 'mergeFile' && this.isDesFormType !== 'arcives' && this.isDesFormType !== 'manageArcives') {
  375. categoryId = this.selectedCategory.pid
  376. } else {
  377. categoryId = this.selectedCategory.id
  378. }
  379. await FetchArchivesClassTree({ 'categoryId': categoryId }).then(res => {
  380. const option = this.getClassfiyNode(res, this.addOrUpdateForm[val.fieldName])
  381. if (option) {
  382. const obj = {}
  383. obj.name = val.name
  384. obj.val = option[0].code + val.connector
  385. obj.sequence = val.sequence
  386. getAutoFiledVal.push(obj)
  387. }
  388. })
  389. }
  390. } else {
  391. const obj = {}
  392. obj.name = val.fieldName
  393. obj.val = this.addOrUpdateForm[val.fieldName] + val.connector
  394. obj.sequence = val.sequence
  395. getAutoFiledVal.push(obj)
  396. }
  397. }
  398. getAutoFiledVal.sort(this.compare('sequence'))
  399. string = getAutoFiledVal.map((item) => item.val).join('')
  400. this.formPreviewData.map(item => {
  401. if (item.isAutomatic) {
  402. this.$set(this.addOrUpdateForm, item.fieldName, string)
  403. }
  404. })
  405. })
  406. },
  407. // 排序
  408. compare(property) {
  409. return function(a, b) {
  410. var value1 = a[property]
  411. var value2 = b[property]
  412. return value1 - value2
  413. }
  414. },
  415. // 获取档号组成项
  416. FetchNoFormatField(categoryId) {
  417. getNoFormatField({ categoryId: categoryId, categoryLevel: this.collectLevel }).then(res => {
  418. this.autoMatic = res
  419. this.handleAuto()
  420. })
  421. },
  422. // 获取对应字典子集数据
  423. getAllSubset(item) {
  424. if (item.mateData === 1) {
  425. this.getFondsDatas(item)
  426. } else if (item.mateData === 2) {
  427. if (item.categoryId) {
  428. this.getClassifyTree(item)
  429. }
  430. } else {
  431. if (item.dictionaryId) {
  432. const params = {
  433. 'pid': item.dictionaryId.id
  434. }
  435. this.isTableType = 3
  436. this.tableTitle = '字典列表'
  437. if (this.selectedCategory.arrangeType === 3 && this.collectLevel === 2 && item.dictionaryId.dictionaryCode === 'project_class') {
  438. this.getDictsList(item)
  439. } else {
  440. FetchSonDictionaryList(params).then(res => {
  441. if (item.isInputClass === 'select') {
  442. this.$set(item, 'options', res)
  443. } else if (item.isInputClass === 'popover') {
  444. this.popoverTableData = res
  445. this.popoverVisible = true
  446. }
  447. })
  448. }
  449. }
  450. }
  451. },
  452. getFondsDatas(item) {
  453. const parent = {}
  454. parent.id = 0
  455. parent.fondsName = '全宗选择'
  456. this.isTableType = 1
  457. this.tableTitle = '全宗列表'
  458. FetchFondsAll().then(res => {
  459. if (item.isInputClass === 'select') {
  460. this.$set(item, 'options', res)
  461. } else if (item.isInputClass === 'popover') {
  462. this.popoverTableDataFonds = res
  463. this.popoverFondsVisible = true
  464. }
  465. })
  466. },
  467. getClassifyTree(item) {
  468. this.isTableType = 2
  469. this.tableTitle = '分类列表'
  470. let categoryId
  471. if (this.isDesFormType !== 'mergeFile' && this.isDesFormType !== 'arcives' && this.isDesFormType !== 'manageArcives') {
  472. categoryId = this.selectedCategory.pid
  473. } else {
  474. categoryId = this.selectedCategory.id
  475. }
  476. FetchArchivesClassTree({ 'categoryId': categoryId }).then(res => {
  477. if (item.isInputClass === 'select') {
  478. const classifyOptions = res.map(function(obj) {
  479. if (obj.childArchivesClass !== null) {
  480. obj.hasChildren = true
  481. } else {
  482. obj.hasChildren = false
  483. }
  484. if (obj.hasChildren) {
  485. obj.children = null
  486. }
  487. return obj
  488. })
  489. this.$set(item, 'options', classifyOptions)
  490. } else if (item.isInputClass === 'popover') {
  491. this.popoverTableDataClassify = res
  492. this.popoverClassifyVisible = true
  493. }
  494. })
  495. },
  496. getSonClass(tree, treeNode, resolve) {
  497. setTimeout(() => {
  498. FetchSonArchivesClass({ pid: tree.id }).then(res => {
  499. const data = res.map(function(obj) {
  500. if (obj.sonNum !== 0 && obj.sonNum) {
  501. obj.hasChildren = true
  502. obj.children = null
  503. } else {
  504. obj.hasChildren = false
  505. }
  506. return obj
  507. })
  508. resolve(data)
  509. })
  510. }, 100)
  511. },
  512. // 判断重复api
  513. handlerIsRepeat(params, item) {
  514. if (this.isDesFormType !== 'prearchiveLibrary') {
  515. FetchDoeditIsRepeat(params).then(res => {
  516. if (res) {
  517. this.$message.error(item.fieldCnName + '不可重复')
  518. }
  519. })
  520. } else {
  521. FetchReDoeditIsRepeat(params).then(res => {
  522. if (res) {
  523. this.$message.error(item.fieldCnName + '不可重复')
  524. }
  525. })
  526. }
  527. },
  528. // input 判断是否重复
  529. isRepeatHandle(item) {
  530. // 自动重复字段 - 是否重复
  531. if (item.isRepeat) {
  532. let params
  533. if (this.isDesFormType !== 'prearchiveLibrary' && this.isDesFormType !== 'mergeFile') {
  534. params = {
  535. 'categoryId': this.selectedCategory.id,
  536. 'archivesId': this.arcId,
  537. 'fieldName': item.fieldName,
  538. 'value': this.addOrUpdateForm[item.fieldName]
  539. }
  540. } else {
  541. params = {
  542. 'documentId': this.selectedCategory.id,
  543. 'archivesId': null,
  544. 'fieldName': item.fieldName,
  545. 'value': this.addOrUpdateForm[item.fieldName]
  546. }
  547. }
  548. this.handlerIsRepeat(params, item)
  549. }
  550. if (this.isDesFormType !== 'prearchiveLibrary' && this.isDesFormType !== 'mergeFile') {
  551. if (!item.isAutomatic) {
  552. const index = this.autoMatic.findIndex(i => item.fieldName === i.fieldName)
  553. if (index !== -1) {
  554. this.handleAuto()
  555. }
  556. }
  557. }
  558. },
  559. // tree - open
  560. openTree(item) {
  561. this.treeCurrentFiled = item
  562. this.$set(item, 'options', [])
  563. this.getAllSubset(this.treeCurrentFiled)
  564. },
  565. // tree - select
  566. selectTree(val) {
  567. if (val.fondsNo) {
  568. this.addOrUpdateForm[this.treeCurrentFiled.fieldName] = val.fondsName
  569. } else if (val.code) {
  570. this.addOrUpdateForm[this.treeCurrentFiled.fieldName] = val.name
  571. } else {
  572. this.addOrUpdateForm[this.treeCurrentFiled.fieldName] = val.dictionaryName
  573. }
  574. // 自动重复字段 - 是否重复 - treeSelect方式
  575. if (this.treeCurrentFiled.isRepeat) {
  576. let params
  577. if (this.isDesFormType !== 'prearchiveLibrary' && this.isDesFormType !== 'mergeFile') {
  578. params = {
  579. 'categoryId': this.selectedCategory.id,
  580. 'archivesId': this.arcId,
  581. 'fieldName': this.treeCurrentFiled.fieldName,
  582. 'value': val.dictionaryName
  583. }
  584. } else {
  585. params = {
  586. 'documentId': this.selectedCategory.id,
  587. 'archivesId': null,
  588. 'fieldName': this.treeCurrentFiled.fieldName,
  589. 'value': val.dictionaryName
  590. }
  591. }
  592. this.handlerIsRepeat(params, this.treeCurrentFiled)
  593. }
  594. if (this.isDesFormType !== 'prearchiveLibrary' && this.isDesFormType !== 'mergeFile') {
  595. if (this.autoMatic) {
  596. const index = this.autoMatic.findIndex(i => this.treeCurrentFiled.fieldName === i.fieldName)
  597. if (index !== -1) {
  598. this.handleAuto()
  599. }
  600. }
  601. }
  602. },
  603. // popover - table 单选
  604. clickRowHandler(row) {
  605. this.$refs.popoverTable.clearSelection()
  606. if (!row.level || row.level === 3) {
  607. this.$refs.popoverTable.toggleRowSelection(row)
  608. } else {
  609. return false
  610. }
  611. },
  612. // popover - table 选中得项
  613. handleSelectionChange(val) {
  614. if (val.length > 0) {
  615. if (this.isTableType === 1) {
  616. this.addOrUpdateForm[this.currentFieldName] = val[0].fondsNo
  617. } else if (this.isTableType === 2 && this.isDesFormType !== 'prearchiveLibrary') {
  618. this.addOrUpdateForm[this.currentFieldName] = val[0].code
  619. } else {
  620. this.addOrUpdateForm[this.currentFieldName] = val[0].dictionaryName
  621. }
  622. }
  623. this.$refs.popoverTable.clearSelection()
  624. this.popoverVisible = false
  625. this.popoverClassifyVisible = false
  626. this.popoverFondsVisible = false
  627. if (this.isDesFormType !== 'prearchiveLibrary' && this.isDesFormType !== 'mergeFile') {
  628. if (this.autoMatic) {
  629. const index = this.autoMatic.findIndex(i => this.currentFieldName === i.fieldName)
  630. if (index !== -1) {
  631. this.handleAuto()
  632. }
  633. }
  634. }
  635. },
  636. // popover - 当前选中得
  637. handleCurrentFieldName(item) {
  638. this.currentFieldName = item.fieldName
  639. this.getAllSubset(item)
  640. },
  641. // 预览和输入时,自动补零
  642. autoAddZero(isFilling, fieldName, value, fillingDigit) {
  643. if (isFilling) {
  644. this.addOrUpdateForm[fieldName] = value.toString().padStart(fillingDigit, '0').slice(-1 * fillingDigit)
  645. }
  646. },
  647. // 寻找pid档案门类代码
  648. findNodeById(node, targetId) {
  649. if (node.id === targetId) {
  650. return node
  651. }
  652. if (node.children && node.children.length > 0) {
  653. for (const child of node.children) {
  654. const result = this.findNodeById(child, targetId)
  655. if (result) {
  656. return result
  657. }
  658. }
  659. }
  660. return null
  661. },
  662. // 动态生成表单
  663. editFormRow() {
  664. this.rules = {}
  665. this.formPreviewData.map(item => {
  666. if (item.isInputClass === 'select') {
  667. this.$set(item, 'options', [])
  668. this.$set(this.addOrUpdateForm, item.fieldName, null) // 防止unkonwn
  669. }
  670. if (item.isDefaultValue !== '') {
  671. this.$set(this.addOrUpdateForm, item.fieldName, item.isDefaultValue)
  672. } else {
  673. this.$set(this.addOrUpdateForm, item.fieldName, '')
  674. if (item.isInputClass === 'select') {
  675. this.$set(this.addOrUpdateForm, item.fieldName, null) // 防止unkonwn
  676. }
  677. }
  678. if (item.fieldName === 'archival_category_code') {
  679. let targetNode
  680. if (this.isDesFormType !== 'mergeFile' && this.isDesFormType !== 'arcives' && this.isDesFormType !== 'manageArcives') {
  681. const targetId = this.selectedCategory.pid
  682. targetNode = this.findNodeById(this.crud.data[0], targetId)
  683. } else {
  684. targetNode = this.selectedCategory
  685. }
  686. if (targetNode) {
  687. this.$set(this.addOrUpdateForm, item.fieldName, targetNode.code)
  688. } else {
  689. this.$set(this.addOrUpdateForm, item.fieldName, '')
  690. }
  691. }
  692. if (item.fieldName === 'is_entity') {
  693. this.$set(this.addOrUpdateForm, item.fieldName, 1)
  694. }
  695. this.$set(this.rules, item.fieldName, [
  696. {
  697. required: !!item.isRequired,
  698. message: (item.isInputClass === 'text' ? '请输入' : '请选择') + item.fieldCnName,
  699. trigger: item.isInputClass === 'text' ? 'blur' : 'change'
  700. }
  701. ])
  702. })
  703. },
  704. // 预览界面排序
  705. datadragEnd(event) {
  706. // 调换顺序
  707. const oldIndex = event.oldIndex // 移动初始位置
  708. const newIndex = event.newIndex // 运动终止位置
  709. const diff = Math.abs(newIndex - oldIndex) // 插值绝对值
  710. const index = this.formPreviewData[oldIndex]
  711. if (oldIndex > newIndex) {
  712. for (let i = 0; i < diff; i++) {
  713. this.formPreviewData[oldIndex - i] = this.formPreviewData[oldIndex - i - 1]
  714. }
  715. this.formPreviewData[newIndex] = index
  716. } else {
  717. for (let i = 0; i < diff; i++) {
  718. this.formPreviewData[oldIndex + i] = this.formPreviewData[oldIndex + i + 1]
  719. }
  720. this.formPreviewData[newIndex] = index
  721. }
  722. },
  723. submitForm(formName, categoryId, quickPaperArcId) {
  724. // 时间格式化
  725. this.formPreviewData.map(item => {
  726. if (item.isInputClass === 'date') {
  727. if (this.addOrUpdateForm[item.fieldName] !== '') {
  728. this.$set(this.addOrUpdateForm, item.fieldName, parseTime(this.addOrUpdateForm[item.fieldName]).split(' ')[0])
  729. }
  730. }
  731. })
  732. if (this.archivesType === 'add') {
  733. this.addOrUpdateForm.fonds_affiliation = this.user.fonds.id
  734. }
  735. console.log(this.addOrUpdateForm)
  736. delete this.addOrUpdateForm.id
  737. this.$refs[formName].validate((valid) => {
  738. if (valid) {
  739. // 预归档库
  740. if (this.isDesFormType === 'prearchiveLibrary') {
  741. delete this.addOrUpdateForm.fileOriginal
  742. const params = {
  743. 'id': this.arcId,
  744. 'ids': null,
  745. 'documentId': categoryId,
  746. 'delMan': null,
  747. 'jsonString': JSON.stringify(this.addOrUpdateForm),
  748. 'fileJsonString': this.fileJsonString
  749. }
  750. console.log(params)
  751. prearchEdit(params).then(res => {
  752. if (res) {
  753. this.$message.success(res)
  754. this.$emit('close-dialog')
  755. this.crud.refresh()
  756. }
  757. })
  758. } else if (this.isDesFormType === 'mergeFile') {
  759. // 合并成件
  760. const params = {
  761. 'archivesId': null,
  762. 'archivesIds': this.mergeFileArcIds,
  763. 'documentId': categoryId,
  764. 'categoryId': this.mergeFileCategory,
  765. 'jsonString': JSON.stringify(this.addOrUpdateForm)
  766. }
  767. FetchMergeToFile(params).then(res => {
  768. if (res) {
  769. this.$message.success(res)
  770. this.$emit('close-dialog')
  771. this.crud.refresh()
  772. }
  773. })
  774. } else {
  775. // 收集库
  776. let parentsId = null
  777. // 2 项目 3 案卷 /文件 4 卷内 6 文件
  778. if (this.isTitleType === 2) {
  779. parentsId = null
  780. } else if (this.isTitleType === 3) {
  781. if (this.selectedCategory.arrangeType === 1) {
  782. parentsId = null
  783. } else {
  784. parentsId = this.parentsData.parentsProjectId
  785. }
  786. } else if (this.isTitleType === 4) {
  787. // 卷内
  788. parentsId = this.parentsData.parentsAnjuanId
  789. } else if (this.isTitleType === 6) {
  790. // 原文
  791. parentsId = this.parentsData.parentsJuanneiId
  792. }
  793. let params
  794. if (quickPaperArcId && quickPaperArcId.length !== 0 && this.archivesType === 'add') {
  795. // 快速组卷时,组卷的文件是数组,所以要archivesIds 而不是 archivesId,正好是新增文件,所以this.arcId = null不用担心
  796. params = {
  797. 'archivesId': this.arcId,
  798. 'archivesIds': quickPaperArcId,
  799. 'categoryId': categoryId,
  800. 'parentsId': parentsId,
  801. 'categoryLevel': 2,
  802. 'jsonString': JSON.stringify(this.addOrUpdateForm)
  803. }
  804. } else if (this.selectedCategory.arrangeType === 3 && this.activeIndex === 1 && this.archivesType === 'add') {
  805. // 在项目下,未整理的文件只属于门类下,不属于任何项目或案卷,所以parentsId === null
  806. params = {
  807. 'archivesId': this.arcId,
  808. 'archivesIds': null,
  809. 'categoryId': categoryId,
  810. 'parentsId': null,
  811. 'categoryLevel': this.collectLevel,
  812. 'jsonString': JSON.stringify(this.addOrUpdateForm)
  813. }
  814. } else {
  815. params = {
  816. 'archivesId': this.arcId,
  817. 'archivesIds': null,
  818. 'categoryId': categoryId,
  819. 'parentsId': parentsId,
  820. 'categoryLevel': this.collectLevel,
  821. 'jsonString': JSON.stringify(this.addOrUpdateForm)
  822. }
  823. }
  824. console.log(params)
  825. if (this.archivesType === 'add') {
  826. collectAdd(params).then(res => {
  827. if (res.code === 200) {
  828. this.$message.success(res)
  829. this.$emit('close-dialog', parentsId)
  830. }
  831. })
  832. } else {
  833. collectEdit(params).then(res => {
  834. console.log(res)
  835. if (res.code === 200) {
  836. this.$message.success(res)
  837. this.$emit('close-dialog', parentsId)
  838. } else {
  839. this.$message.error(res.message)
  840. this.$emit('close-dialog', parentsId)
  841. }
  842. })
  843. }
  844. }
  845. } else {
  846. console.log('error submit!!')
  847. return false
  848. }
  849. })
  850. },
  851. handleClose(done) {
  852. this.popoverVisible = false
  853. this.popoverClassifyVisible = false
  854. this.popoverFondsVisible = false
  855. this.popoverTableData = []
  856. this.popoverTableDataClassify = []
  857. this.popoverTableDataFonds = []
  858. done()
  859. },
  860. // 选择附件
  861. async changeFile(e) {
  862. this.file = e.target.files[0]
  863. this.fileSize = this.file.size
  864. this.formatType = this.file.type.substring(0, this.file.type.indexOf('/'))
  865. this.fileNames = this.file.name
  866. this.postfix = this.file.name.substring(
  867. this.fileNames.lastIndexOf('.') + 1,
  868. this.fileNames.length
  869. )
  870. if (this.formatType === 'image') {
  871. const fileBase64 = await this.getBase64(this.file)
  872. const res = await this.getImgPx(fileBase64)
  873. this.px = res.width + 'px*' + res.height + 'px'
  874. } else {
  875. this.px = ''
  876. }
  877. // 上传附件
  878. reDocumentUpload(this.baseApi + '/api/re-document/uploadFile', this.file, this.selectedDocument.id).then(res => {
  879. if (res.data.code === 200) {
  880. this.filePath = res.data.data
  881. this.uploadSave()
  882. }
  883. })
  884. },
  885. // 上传附件 - 选择上传即保存
  886. uploadSave() {
  887. this.nowDate = getCurrentTime()
  888. const json = {
  889. 'file_name': this.fileNames,
  890. 'file_size': this.fileSize,
  891. 'file_type': this.postfix,
  892. 'file_path': this.filePath,
  893. 'sequence': null,
  894. 'archive_id': this.arcId,
  895. 'file_dpi': this.px,
  896. 'file_thumbnail': '',
  897. 'create_time': this.nowDate,
  898. 'id': null,
  899. 'is_quote': null
  900. }
  901. const arrayUpload = []
  902. arrayUpload.push(json)
  903. // this.addOrUpdateForm.fileOriginal = this.fileNames
  904. this.$set(this.addOrUpdateForm, 'fileOriginal', this.fileNames)
  905. this.fileJsonString = JSON.stringify(arrayUpload)
  906. },
  907. // 将上传的图片转为base64
  908. getBase64(file) {
  909. const reader = new FileReader()
  910. reader.readAsDataURL(file)
  911. return new Promise((resolve) => {
  912. reader.onload = () => {
  913. resolve(reader.result)
  914. }
  915. })
  916. },
  917. // 获取图片的分辨率
  918. getImgPx(img) {
  919. const image = new Image()
  920. image.src = img
  921. return new Promise((resolve) => {
  922. image.onload = () => {
  923. const width = image.width
  924. const height = image.height
  925. resolve({ width, height })
  926. }
  927. })
  928. },
  929. // 项目级别 - 阶段分类
  930. getDictsList(item) {
  931. FetchDictionaryTree().then((res) => {
  932. const filterCodes = ['project_class']
  933. let filteredItems = JSON.parse(JSON.stringify(res)).filter(item => filterCodes.includes(item.dictionaryCode))
  934. filteredItems = this.addLevelToDictionaryList(filteredItems, 1)
  935. if (item.isInputClass === 'select') {
  936. this.$set(item, 'options', filteredItems)
  937. } else if (item.isInputClass === 'popover') {
  938. this.popoverTableData = filteredItems
  939. this.popoverVisible = true
  940. }
  941. }).catch(err => {
  942. console.log(err)
  943. })
  944. },
  945. // 给筛选出来的数据加level 方便后面是否可点击
  946. addLevelToDictionaryList(dictionaryList, level) {
  947. dictionaryList.forEach(dictionary => {
  948. dictionary.level = level
  949. if (dictionary.childDictionarys) {
  950. dictionary.childDictionarys = this.addLevelToDictionaryList(dictionary.childDictionarys, level + 1)
  951. }
  952. })
  953. return dictionaryList
  954. }
  955. }
  956. }
  957. </script>
  958. <style lang="scss" scoped>
  959. @import "~@/assets/styles/mixin.scss";
  960. @import "~@/assets/styles/variables.scss";
  961. @mixin preview-border-style{
  962. [data-theme="dark"] & {
  963. border: 1px solid #3a99fd;
  964. }
  965. [data-theme="light"] & {
  966. border: 1px solid #EDEFF3;
  967. }
  968. }
  969. @mixin preview-border-color{
  970. [data-theme="dark"] & {
  971. // border-color: #3a99fd;
  972. border-color: #EDEFF3;
  973. }
  974. [data-theme="light"] & {
  975. border-color: #EDEFF3;
  976. }
  977. }
  978. .preview-content {
  979. padding: 20px 0 0 0 !important;
  980. margin-top: 0 !important;
  981. border-radius: 4px;
  982. margin: 0 auto;
  983. border: 1px solid;
  984. @include preview-border-color;
  985. .el-row {
  986. margin-left: 0 !important;
  987. margin-right: 0 !important;
  988. }
  989. .el-col {
  990. padding-left: 0 !important;
  991. padding-right: 0 !important;
  992. }
  993. ::v-deep .el-form-item__label{
  994. @include tree_font_color;
  995. }
  996. ::v-deep .el-input__inner,
  997. ::v-deep .vue-treeselect__control,
  998. ::v-deep .el-textarea__inner {
  999. width: 100%;
  1000. background-color: transparent;
  1001. @include input_style;
  1002. }
  1003. ::v-deep .vue-treeselect__control{
  1004. height: 32px !important;
  1005. }
  1006. ::v-deep .el-input__prefix {
  1007. text-align: right;
  1008. right: 5px !important;
  1009. @include tree_font_color;
  1010. }
  1011. .input-popover {
  1012. ::v-deep .el-input__suffix {
  1013. @include tree_font_color;
  1014. }
  1015. }
  1016. ::v-deep .el-date-editor {
  1017. width: 225px;
  1018. .el-input__inner {
  1019. padding-left: 15px;
  1020. }
  1021. }
  1022. ::v-deep .el-form-item--small .el-form-item__content {
  1023. line-height: 30px;
  1024. }
  1025. ::v-deep .el-input.is-disabled .el-input__inner{
  1026. background-color: #f5f7fa;
  1027. color: #c0c4cc;
  1028. }
  1029. }
  1030. .preview-form-bottom{
  1031. padding: 20px 20px 0 20px;
  1032. border-top: 1px solid;
  1033. @include preview-border-color;
  1034. }
  1035. .prearch-bottom{
  1036. position: fixed;
  1037. bottom: 72px;
  1038. left: 0;
  1039. background: #fff;
  1040. width: 100%;
  1041. padding: 20px 0 0 20px;
  1042. }
  1043. .prearch-upload{
  1044. margin-right: 0 !important;
  1045. ::v-deep .el-form-item__content{
  1046. width: 540px !important;
  1047. display: flex;
  1048. justify-content: space-between;
  1049. .upload-btn{
  1050. position: relative;
  1051. width:96px;
  1052. margin-right: 0 !important;
  1053. margin-left: 10px;
  1054. overflow: initial !important;
  1055. #upFile{
  1056. position: absolute;
  1057. left: 0;
  1058. top: 0;
  1059. // opacity: 0;
  1060. width: 84px;
  1061. height: 34px;
  1062. }
  1063. .el-button{
  1064. margin-top: -2px;
  1065. font-weight: bold;
  1066. border-color: #0348f3;
  1067. color: #0348f3;
  1068. }
  1069. }
  1070. }
  1071. }
  1072. </style>