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

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