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

540 lines
19 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
  1. <template>
  2. <div>
  3. <!-- 批量成件 -->
  4. <el-dialog class="batch-form" append-to-body :modal-append-to-body="false" :close-on-click-modal="false" :before-close="handleClose" :visible="batchVisible" title="批量成件">
  5. <span class="dialog-right-top" />
  6. <span class="dialog-left-bottom" />
  7. <div class="setting-dialog">
  8. <el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="130px">
  9. <el-form-item label="对应规则" prop="rules">
  10. <el-select v-model="form.ruleName" placeholder="请选择" style="width: 225px;" @change="selectRules">
  11. <el-option
  12. v-for="item in rulesOptions"
  13. :key="item.value"
  14. :label="item.label"
  15. :value="item.value"
  16. />
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="归档范围" prop="scope">
  20. <el-input v-model="form.scope" type="text" readonly>
  21. <i slot="suffix" class="el-input__icon iconfont icon-sousuo" @click="selectScope" />
  22. </el-input>
  23. </el-form-item>
  24. <el-form-item label="源分类" prop="documentName">
  25. <el-input v-model="form.documentName" type="text" disabled />
  26. </el-form-item>
  27. <el-form-item label="目标门类" prop="categoryId">
  28. <treeselect
  29. v-model="form.categoryId"
  30. :options="categoryTree"
  31. flat
  32. :multiple="false"
  33. :normalizer="normalizer"
  34. :default-expand-level="6"
  35. placeholder="请选择目标门类(整理库/管理库门类)"
  36. @select="handleSelectCategory"
  37. />
  38. </el-form-item>
  39. </el-form>
  40. <div v-loading="fieldLoading" class="corres-field-main">
  41. <div class="corres-field-list corres-field-left">
  42. <div class="corres-field-title">
  43. <p>字段取值</p>
  44. </div>
  45. <div class="field-list">
  46. <div v-for="(item, index) in selectStatus" :key="index" class="field-item">
  47. <el-select :key="index" v-model="item.fiedType" @change="selectChangeFiedType(index)">
  48. <el-option
  49. v-for="v in fiedOption"
  50. :key="v.value"
  51. :label="v.label"
  52. :value="v.value"
  53. />
  54. </el-select>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="corres-field-list corres-field-middle">
  59. <div class="corres-field-title">
  60. <p>源分类文件库-文件表</p>
  61. <span>{{ form.documentName }}</span>
  62. </div>
  63. <div v-loading="leftLoading" class="field-list">
  64. <div v-for="(item, index) in selectStatus" :key="index" class="field-item">
  65. <el-select v-if="item.mode" :key="index" v-model="item.value" @change="selectChange(index)">
  66. <el-option value="">请选择</el-option>
  67. <el-option
  68. v-for="v in options"
  69. :key="v.id"
  70. :label="v.fieldCnName"
  71. :value="v.fieldCnName"
  72. />
  73. </el-select>
  74. <p v-if="!item.mode" @click="textMode(index)">
  75. {{ item.value }}
  76. </p>
  77. </div>
  78. </div>
  79. </div>
  80. <div class="corres-field-list corres-field-right">
  81. <div class="corres-field-title">
  82. <p>目标门类整理库/管理库-文件表</p>
  83. <span>{{ selectedCategoryName }}</span>
  84. </div>
  85. <div v-loading="rightLoading" class="field-list">
  86. <div v-if="isCorrField">
  87. <div v-for="(item,index) in allFieldData" :key="index" class="field-item">
  88. <p>{{ item.categoryFieldId.fieldCnName }}</p>
  89. <div class="field-state"><span :class=" item.categoryFieldId.isInput ? 'is-select' : 'is-hide'">{{ item.categoryFieldId.isInput ? '显示': '隐藏' }}</span></div>
  90. </div>
  91. </div>
  92. <div v-else>
  93. <div v-for="(item,index) in allCorrField" :key="index" class="field-item">
  94. <p>{{ item.fieldCnName }}</p>
  95. <div class="field-state"><span :class=" item.isInput ? 'is-select' : 'is-hide'">{{ item.isInput ? '显示': '隐藏' }}</span></div>
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. <div v-if="allFieldData.length === 0 && allCorrField.length === 0" class="empty-data" />
  101. </div>
  102. <div slot="footer" class="dialog-footer">
  103. <el-button type="text" @click="handleClose">取消</el-button>
  104. <el-button type="primary" @click="handleComfirmBatchToFile">确定</el-button>
  105. </div>
  106. </div>
  107. </el-dialog>
  108. <ScopeModule ref="scopeModule" @getScope="hanleScopeSelect" />
  109. </div>
  110. </template>
  111. <script>
  112. import { preLibraryCrud } from '../mixins/index'
  113. import { FetchInitFieldMate, FetchMateByDocumentId, FetchDetailsByDocumentIdAndCategoryId } from '@/api/system/fieldMate'
  114. import { FetchInitDocumentFieldByPid } from '@/api/system/fileLibrary/fileLibrary'
  115. import { FetchCategoryMenu, FetchInitCategoryFieldByPid } from '@/api/system/category/category'
  116. import { FetchArchivesScopeByCategoryId } from '@/api/system/archivesScope'
  117. import { FetchCheckRepeat } from '@/api/system/fieldMate'
  118. import { FetchBatchToFile } from '@/api/prearchiveLibrary/prearchiveLibrary'
  119. import Treeselect from '@riophae/vue-treeselect'
  120. import '@riophae/vue-treeselect/dist/vue-treeselect.css'
  121. // import { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
  122. import ScopeModule from './scope'
  123. export default {
  124. name: 'BatchFile',
  125. components: { Treeselect, ScopeModule },
  126. mixins: [preLibraryCrud],
  127. props: {
  128. selectedDocument: {
  129. type: Object,
  130. default: function() {
  131. return {}
  132. }
  133. }
  134. },
  135. data() {
  136. return {
  137. selectionsArc: [],
  138. batchVisible: false,
  139. rulesOptions: [],
  140. categoryTree: [],
  141. form: {
  142. ruleName: null,
  143. scope: null,
  144. documentId: null,
  145. documentName: '',
  146. categoryId: null
  147. },
  148. batchCategory: {},
  149. selectedCategoryName: null,
  150. scopeVisible: false,
  151. loadSource: [],
  152. rules: {
  153. categoryId: [
  154. { required: true, message: '请选择档案门类', trigger: 'change' }
  155. ]
  156. },
  157. fiedOption: [{
  158. 'label': '默认值',
  159. 'value': 2
  160. }, {
  161. 'label': '字段值',
  162. 'value': 1
  163. }],
  164. fiedType: null,
  165. selectStatus: [],
  166. selectOptions: [],
  167. options: [],
  168. fieldLoading: false,
  169. allFieldData: [],
  170. targetData: [],
  171. leftLoading: false,
  172. rightLoading: false,
  173. isCorrField: true,
  174. allCorrField: [],
  175. isTest: false
  176. }
  177. },
  178. watch: {
  179. selectedDocument: function(newValue, oldValue) {
  180. this.form.documentName = newValue.cnName
  181. this.getMateByDocumentId()
  182. this.getCategoryDataTree()
  183. }
  184. },
  185. created() {
  186. },
  187. mounted() {
  188. },
  189. methods: {
  190. // 根据预归档库获取对应规则
  191. getMateByDocumentId() {
  192. const params = {
  193. 'documentId': this.selectedDocument.id
  194. }
  195. FetchMateByDocumentId(params).then(res => {
  196. this.rulesOptions = res.map(item => {
  197. const json = {}
  198. json.label = item.ruleName
  199. json.value = item.id
  200. return json
  201. })
  202. })
  203. },
  204. getInitDetail(id) {
  205. FetchInitFieldMate({ 'id': id }).then((res) => {
  206. this.selectedCategoryName = res.categoryName
  207. this.batchCategory = res.fieldMateDetails[0].pid.categoryId
  208. this.form.categoryId = res.fieldMateDetails[0].pid.categoryId.pid
  209. this.getArchivesScopeByCategoryId()
  210. }).catch(err => {
  211. console.log(err)
  212. })
  213. },
  214. selectRules(val) {
  215. this.getInitDetail(val)
  216. this.selectStatus = []
  217. this.allFieldData = []
  218. this.allCorrField = []
  219. this.isCorrField = true
  220. this.isTest = false
  221. },
  222. // 目标门类
  223. getCategoryDataTree() {
  224. FetchCategoryMenu().then(res => {
  225. this.categoryTree = this.filterData(res)
  226. })
  227. },
  228. // 根据pid获取门类字段
  229. initDocunmentFiledList(documentId) {
  230. // 文件库字段
  231. this.leftLoading = true
  232. FetchInitDocumentFieldByPid({ documentId: documentId, isType: 2 }).then((res) => {
  233. this.options = res.sort((a, b) => {
  234. if (a.isInput !== b.isInput) {
  235. return a.isInput ? -1 : 1
  236. } else {
  237. return a.isSequence - b.isSequence
  238. }
  239. })
  240. this.leftLoading = false
  241. })
  242. },
  243. // 根据pid获取门类字段
  244. initCategoryFiledList(categoryId) {
  245. // 门类字段
  246. this.rightLoading = true
  247. FetchInitCategoryFieldByPid({ categoryId: categoryId, isType: 2 }).then((res) => {
  248. this.allCorrField = res.sort((a, b) => {
  249. if (a.isInput !== b.isInput) {
  250. return a.isInput ? -1 : 1
  251. } else {
  252. return a.isSequence - b.isSequence
  253. }
  254. })
  255. res.forEach((item, index) => {
  256. this.selectStatus.push({ mode: true, fiedType: 1, value: '', field: item, isInput: item.isInput })
  257. })
  258. this.rightLoading = false
  259. })
  260. },
  261. // 根据预归档库和门类获取详情
  262. getDetailsByDocumentIdAndCategoryId() {
  263. this.fieldLoading = true
  264. const params = {
  265. 'categoryId': this.form.categoryId,
  266. 'documentId': this.selectedDocument.id
  267. }
  268. this.initDocunmentFiledList(this.selectedDocument.id,)
  269. FetchDetailsByDocumentIdAndCategoryId(params).then(res => {
  270. this.allFieldData = res
  271. res.forEach((item, index) => {
  272. this.selectStatus.push({ mode: false, fiedType: item.categoryFieldId.isDefaultValue === '' ? 1 : 2, value: item.categoryFieldId.isDefaultValue === '' ? item.documentFieldId.fieldCnName : item.categoryFieldId.isDefaultValue, field: item.documentFieldId, isInput: item.documentFieldId.isInput })
  273. })
  274. this.fieldLoading = false
  275. })
  276. },
  277. // 根据子门类id获取档案归档范围
  278. getArchivesScopeByCategoryId() {
  279. const params = {
  280. 'categoryId': this.form.categoryId
  281. }
  282. FetchArchivesScopeByCategoryId(params).then(res => {
  283. console.log(res)
  284. if (Array.isArray(res) && res.length === 1) {
  285. this.form.scope = res[0].scopeName
  286. } else {
  287. this.form.scope = null
  288. console.log('有多个“归档范围”')
  289. }
  290. this.getDetailsByDocumentIdAndCategoryId()
  291. })
  292. },
  293. handleSelectCategory(val) {
  294. console.log(val)
  295. this.selectedCategoryName = val.cnName
  296. this.form.categoryId = val.id
  297. this.batchCategory = val
  298. // this.getArchivesScopeByCategoryId()
  299. const params = {
  300. 'categoryId': this.form.categoryId
  301. }
  302. FetchArchivesScopeByCategoryId(params).then(res => {
  303. if (Array.isArray(res) && res.length === 1) {
  304. this.form.scope = res[0].scopeName
  305. } else {
  306. this.form.scope = null
  307. console.log('有多个“归档范围”')
  308. }
  309. this.getCheckRepeat()
  310. })
  311. },
  312. // 归档范围选择
  313. selectScope() {
  314. this.$refs.scopeModule.scopeVisible = true
  315. this.$nextTick(() => {
  316. if (this.form.categoryId) {
  317. this.$refs.scopeModule.$refs.tree2.setCurrentKey(this.form.categoryId)
  318. this.$refs.scopeModule.handleNodeClick2(this.batchCategory)
  319. }
  320. })
  321. },
  322. hanleScopeSelect(val, category) {
  323. if (val.length !== 0) {
  324. this.form.scope = val[0].scopeName
  325. this.form.categoryId = category.id
  326. this.batchCategory = category
  327. this.selectedCategoryName = category.cnName
  328. this.$nextTick(() => {
  329. this.getCheckRepeat()
  330. })
  331. }
  332. },
  333. getCheckRepeat() {
  334. const params = {
  335. 'categoryId': this.form.categoryId,
  336. 'documentId': this.selectedDocument.id
  337. }
  338. this.fieldLoading = true
  339. FetchCheckRepeat(params).then((res) => {
  340. if (JSON.stringify(res) === JSON.stringify({})) {
  341. console.log('不存在对应关系')
  342. this.isCorrField = false
  343. this.$message({
  344. message: '目标门类与当前源分类不存在对应关系',
  345. type: 'warning'
  346. })
  347. this.form.ruleName = null
  348. this.selectStatus = []
  349. this.initDocunmentFiledList(this.selectedDocument.id)
  350. this.initCategoryFiledList(this.form.categoryId)
  351. } else {
  352. console.log('存在对应关系')
  353. this.isCorrField = true
  354. this.selectStatus = []
  355. this.allFieldData = []
  356. this.form.ruleName = res.id
  357. this.getDetailsByDocumentIdAndCategoryId()
  358. }
  359. this.fieldLoading = false
  360. })
  361. },
  362. // 切换 "字段值" / "默认值"
  363. selectChangeFiedType(index) {
  364. this.options.forEach((item) => {
  365. if (this.selectStatus[index].fiedType === 2) {
  366. if (!this.isCorrField) {
  367. this.selectStatus.splice(index, 1, { mode: false, fiedType: this.selectStatus[index].fiedType, value: this.selectStatus[index].fiedType === 1 ? this.selectStatus[index].value : this.allCorrField[index].isDefaultValue, field: item, isInput: item.isInput })
  368. } else {
  369. this.selectStatus.splice(index, 1, { mode: false, fiedType: this.selectStatus[index].fiedType, value: this.allFieldData[index].categoryFieldId.isDefaultValue, field: item, isInput: item.isInput })
  370. }
  371. } else {
  372. if (!this.isCorrField) {
  373. this.isTest = true
  374. } else {
  375. this.isTest = false
  376. }
  377. this.selectStatus.splice(index, 1, { mode: true, fiedType: this.selectStatus[index].fiedType, value: '', field: item, isInput: item.isInput })
  378. }
  379. })
  380. },
  381. selectChange(index) {
  382. this.options.forEach((item) => {
  383. if (!this.isCorrField && this.allCorrField[index].isDefaultValue !== '') {
  384. if (this.isTest) {
  385. this.selectStatus.splice(index, 1, { mode: false, fiedType: 1, value: this.selectStatus[index].value, field: item, isInput: item.isInput })
  386. } else {
  387. this.selectStatus.splice(index, 1, { mode: false, fiedType: 2, value: this.allCorrField[index].isDefaultValue === '' ? this.selectStatus[index].value : this.allCorrField[index].isDefaultValue, field: item, isInput: item.isInput })
  388. }
  389. } else {
  390. if (this.selectStatus[index].fiedType === 1) {
  391. this.selectStatus.splice(index, 1, { mode: false, fiedType: 1, value: this.selectStatus[index].value, field: item, isInput: item.isInput })
  392. } else {
  393. if (item.fieldCnName === this.selectStatus[index].value) {
  394. this.selectStatus.splice(index, 1, { mode: false, fiedType: this.allFieldData[index].categoryFieldId.isDefaultValue === '' ? 1 : 2, value: this.allFieldData[index].categoryFieldId.isDefaultValue === '' ? this.selectStatus[index].value : this.allFieldData[index].categoryFieldId.isDefaultValue, field: item, isInput: item.isInput })
  395. }
  396. }
  397. }
  398. })
  399. },
  400. textMode(index) {
  401. if (this.selectStatus[index].fiedType === 1) {
  402. this.selectStatus.splice(index, 1, { mode: true, fiedType: 1, value: this.selectStatus[index].value, field: null, isInput: this.selectStatus[index].isInput })
  403. }
  404. },
  405. handleClose(done) {
  406. this.batchVisible = false
  407. Object.assign(this.form, {
  408. ruleName: null,
  409. scope: null,
  410. documentId: null,
  411. categoryId: null
  412. })
  413. this.selectedCategoryName = null
  414. this.allFieldData = []
  415. this.allCorrField = []
  416. this.isTest = false
  417. this.batchCategory = {}
  418. // done()
  419. },
  420. handleComfirmBatchToFile() {
  421. // const getIndicesByMode = (modeValue) => {
  422. // return this.selectStatus.reduce((indices, item, index) => {
  423. // if (item.mode === modeValue) {
  424. // indices.push(index)
  425. // }
  426. // return indices
  427. // }, [])
  428. // }
  429. // const indices = getIndicesByMode(false)
  430. // const arrAL = this.selectStatus.map(item => {
  431. // if (item.hasOwnProperty('field')) {
  432. // return {
  433. // documentValue: item['field'].fieldName,
  434. // getType: item.fiedType // 在field字段中添加getType字段并赋值
  435. // }
  436. // } else {
  437. // return item
  438. // }
  439. // })
  440. // console.log(arrAL)
  441. const dtos = this.allFieldData.map((item, index) => {
  442. return {
  443. 'categoryValue': item.categoryFieldId.fieldName,
  444. 'documentValue': this.selectStatus[index].fiedType === 2 ? item.categoryFieldId.isDefaultValue : this.selectStatus[index].field.fieldName,
  445. 'getType': this.selectStatus[index].fiedType,
  446. 'isRequired': item.categoryFieldId.isRequired
  447. }
  448. })
  449. const archivesIds = this.selectionsArc.map(item => {
  450. return item.id
  451. })
  452. const params = {
  453. 'archivesIds': archivesIds,
  454. 'documentId': this.selectedDocument.id,
  455. 'categoryId': this.form.categoryId,
  456. 'dtos': dtos
  457. }
  458. console.log(params)
  459. FetchBatchToFile(params).then((res) => {
  460. console.log(res)
  461. if (res === 'SUCCESS') {
  462. this.$emit('refresh')
  463. this.batchVisible = false
  464. Object.assign(this.form, {
  465. ruleName: null,
  466. scope: null,
  467. documentId: null,
  468. categoryId: null
  469. })
  470. this.selectedCategoryName = null
  471. this.allFieldData = []
  472. }
  473. })
  474. },
  475. normalizer(node) {
  476. if (node.children && !node.children.length) {
  477. delete node.children
  478. }
  479. return {
  480. id: node.id,
  481. label: node.cnName,
  482. children: node.children,
  483. isDisabled: node.isType !== 2
  484. }
  485. }
  486. }
  487. }
  488. </script>
  489. <style lang="scss" scoped>
  490. @import "~@/assets/styles/prearchive-library.scss";
  491. .batch-form{
  492. ::v-deep .el-dialog{
  493. width: 828px !important;
  494. }
  495. .corres-field-left{
  496. width: 146px;
  497. .corres-field-title{
  498. p{
  499. padding-top: 0 !important;
  500. line-height: 60px;
  501. }
  502. }
  503. .field-list{
  504. .field-item{
  505. width: 146px;
  506. ::v-deep .el-select{
  507. width: 145px !important;
  508. border-right: none;
  509. }
  510. }
  511. }
  512. }
  513. .corres-field-middle{
  514. .field-list{
  515. .field-item{
  516. width: 315px;
  517. ::v-deep .el-select{
  518. width: 314px !important;
  519. border-right: none;
  520. }
  521. }
  522. }
  523. }
  524. }
  525. .corres-field-main{
  526. position: relative;
  527. }
  528. .empty-data{
  529. position: absolute;
  530. top: 60px;
  531. left: 0;
  532. width: 100%;
  533. height: calc(100% - 60px);
  534. background: url('~@/assets/images/system/zwsj.png') no-repeat center center #fff;
  535. background-size: 282px 182px;
  536. }
  537. </style>