阅行客电子档案
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.

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