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

378 lines
14 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
  1. <template>
  2. <div class="app-container row-container">
  3. <!--工具栏-->
  4. <div class="head-container">
  5. <div class="head-search">
  6. <!-- 搜索 -->
  7. <el-input v-model="query.ruleName" clearable size="small" placeholder="输入规则名称搜索" prefix-icon="el-icon-search" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
  8. <!-- @input="changePid" -->
  9. <treeselect
  10. v-model="query.documentId"
  11. :options="documentTree"
  12. style="width: 320px;"
  13. flat
  14. :multiple="false"
  15. :normalizer="normalizer"
  16. placeholder="请选择源分类(文件库分类)"
  17. />
  18. <treeselect
  19. v-model="query.categoryId"
  20. :options="categoryTree"
  21. style="width: 320px;"
  22. flat
  23. :multiple="false"
  24. :normalizer="normalizer"
  25. placeholder="请选择目标门类(整理库/管理库门类)"
  26. />
  27. <rrOperation />
  28. </div>
  29. <crudOperation :permission="permission">
  30. <template v-slot:middle>
  31. <el-button size="mini" :disabled="crud.selections.length !== 1" @click="toEdit(crud.selections[0])">
  32. <i class="iconfont icon-bianji" />
  33. 编辑
  34. </el-button>
  35. </template>
  36. <template v-slot:right>
  37. <el-button :loading="crud.downloadLoading" size="mini" :disabled="crud.selections.length === 0" @click="doExport(crud.selections)">
  38. <i class="iconfont icon-daochu" />
  39. 导出
  40. </el-button>
  41. </template>
  42. </crudOperation>
  43. </div>
  44. <!--表单渲染-->
  45. <el-dialog class="dialog-middle" append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" title="新增对应">
  46. <div class="setting-dialog">
  47. <el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="80px">
  48. <el-form-item label="源分类" prop="documentId">
  49. <treeselect
  50. v-model="form.documentId"
  51. :options="documentTree"
  52. style="width: 400px;"
  53. flat
  54. :multiple="false"
  55. :normalizer="normalizer"
  56. placeholder="请选择源分类(文件库分类)"
  57. @select="handleSelectDocument"
  58. />
  59. </el-form-item>
  60. <el-form-item label="目标门类" prop="categoryId">
  61. <treeselect
  62. v-model="form.categoryId"
  63. :options="categoryTree"
  64. style="width: 400px;"
  65. flat
  66. :multiple="false"
  67. :normalizer="normalizer"
  68. placeholder="请选择目标门类(整理库/管理库门类)"
  69. @select="handleSelectCategory"
  70. />
  71. </el-form-item>
  72. </el-form>
  73. <div slot="footer" class="dialog-footer">
  74. <el-button type="text" @click="crud.cancelCU">取消</el-button>
  75. <el-button :loading="crud.status.cu === 2" type="primary" @click="toCorresForm('form')">确定</el-button>
  76. </div>
  77. </div>
  78. </el-dialog>
  79. <eForm ref="corresForm" />
  80. <DetailModule ref="detail" />
  81. <!--表格渲染-->
  82. <div class="container-wrap">
  83. <span class="right-top-line" />
  84. <span class="left-bottom-line" />
  85. <el-table
  86. ref="table"
  87. v-loading="crud.loading"
  88. :data="crud.data"
  89. row-key="id"
  90. @select="crud.selectChange"
  91. @select-all="crud.selectAllChange"
  92. @selection-change="crud.selectionChangeHandler"
  93. @cell-dblclick="tableDoubleClick"
  94. >
  95. <el-table-column type="selection" width="55" />
  96. <el-table-column :show-overflow-tooltip="true" prop="rule_name" label="规则名称" />
  97. <el-table-column :show-overflow-tooltip="true" prop="documentName" label="源分类(文件库-文件表)" />
  98. <el-table-column :show-overflow-tooltip="true" prop="categoryName" label=" 目标门类(整理库/管理库-文件表)" />
  99. <el-table-column :show-overflow-tooltip="true" prop="mate_num" label="已对应字段数量" />
  100. <el-table-column prop="create_time" label="创建日期" width="200px">
  101. <template slot-scope="scope">
  102. <div>{{ scope.row.create_time | parseTime }}</div>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. </div>
  107. </div>
  108. </template>
  109. <script>
  110. // 获取文件库树
  111. import { FetchDocumentMenu, FetchInitDocumentFieldByPid, FetchInitDocumentField } from '@/api/system/fileLibrary/fileLibrary'
  112. // 获取档案门类树
  113. import { FetchCategoryMenu, FetchInitCategoryFieldByPid, FetchInitCategoryField } from '@/api/system/category/category'
  114. import crudFieldMate from '@/api/system/fieldMate'
  115. import Treeselect from '@riophae/vue-treeselect'
  116. import '@riophae/vue-treeselect/dist/vue-treeselect.css'
  117. // import { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
  118. import CRUD, { presenter, header, form, crud } from '@crud/crud'
  119. import rrOperation from '@crud/RR.operation'
  120. import crudOperation from '@crud/CRUD.operation'
  121. import eForm from './module/form'
  122. import DetailModule from './module/detail'
  123. import { exportFile } from '@/utils/index'
  124. import qs from 'qs'
  125. import { mapGetters } from 'vuex'
  126. // crud交由presenter持有
  127. const defaultForm = { documentId: null, categoryId: null }
  128. export default {
  129. name: 'FieldCorresManage',
  130. components: { crudOperation, rrOperation, Treeselect, eForm, DetailModule },
  131. cruds() {
  132. return CRUD({
  133. title: '对应关系',
  134. url: 'api/fieldMate/initFieldMateList',
  135. crudMethod: { ...crudFieldMate },
  136. optShow: {
  137. add: true,
  138. edit: false,
  139. del: true,
  140. reset: false,
  141. download: false,
  142. group: false
  143. }
  144. })
  145. },
  146. mixins: [presenter(), header(), form(defaultForm), crud()],
  147. data() {
  148. return {
  149. permission: {
  150. add: ['admin', 'fieldMate:add'],
  151. edit: ['admin', 'fieldMate:edit'],
  152. del: ['admin', 'fieldMate:del']
  153. },
  154. categoryTree: [],
  155. documentTree: [],
  156. selectedCategoryName: null,
  157. selectedDocumentName: null,
  158. rules: {
  159. documentId: [
  160. { required: true, message: '请选择源分类(文件库分类)', trigger: 'input' }
  161. ],
  162. categoryId: [
  163. { required: true, message: '请选择目标门类(整理库/管理库门类)', trigger: 'input' }
  164. ]
  165. }
  166. }
  167. },
  168. computed: {
  169. ...mapGetters([
  170. 'baseApi'
  171. ])
  172. },
  173. created() {
  174. this.getCategoryDataTree()
  175. this.getDocumentDataTree()
  176. },
  177. methods: {
  178. filterData(data) {
  179. return data.filter(node => {
  180. if (node.children && node.children.length > 0) {
  181. node.children = this.filterData(node.children) // 递归处理子节点
  182. }
  183. return node.isType !== 3 // 过滤掉isType为3的节点
  184. })
  185. },
  186. getCategoryDataTree() {
  187. FetchCategoryMenu().then(res => {
  188. this.categoryTree = this.filterData(res)
  189. })
  190. },
  191. getDocumentDataTree() {
  192. FetchDocumentMenu().then(res => {
  193. this.documentTree = this.filterData(res)
  194. })
  195. },
  196. handleSelectCategory(val) {
  197. this.selectedCategoryName = val.cnName
  198. },
  199. handleSelectDocument(val) {
  200. this.selectedDocumentName = val.cnName
  201. },
  202. toCorresForm(formName) {
  203. this.$refs[formName].validate((valid) => {
  204. if (valid) {
  205. crudFieldMate.FetchCheckRepeat(this.form).then((res) => {
  206. this.initFiledList(this.form.documentId, this.form.categoryId)
  207. if (JSON.stringify(res) === JSON.stringify({})) {
  208. // 不存在对应关系时
  209. this.$refs.corresForm.corresVisible = true
  210. this.$refs.corresForm.title = '新增对应关系'
  211. this.$refs.corresForm.documentName = null
  212. this.$refs.corresForm.cuform.documentId = this.form.documentId
  213. this.$refs.corresForm.categoryName = this.selectedCategoryName
  214. this.$refs.corresForm.cuform.categoryId = this.form.categoryId
  215. } else {
  216. // 存在对应关系时
  217. this.$confirm('当前所选存在对应关系,点击继续会进入编辑操作' + this.crud.title + '<span>你是否还要继续?</span>', '提示', {
  218. confirmButtonText: '继续',
  219. cancelButtonText: '取消',
  220. type: 'warning',
  221. dangerouslyUseHTMLString: true
  222. }).then(() => {
  223. this.$refs.corresForm.title = '编辑对应关系'
  224. this.$refs.corresForm.corresVisible = true
  225. this.editGetMate(res.id)
  226. }).catch((err) => {
  227. console.log(err)
  228. })
  229. }
  230. })
  231. } else {
  232. console.log('error submit!!')
  233. return false
  234. }
  235. })
  236. },
  237. // 根据pid获取门类字段
  238. initFiledList(documentId, categoryId) {
  239. this.$refs.corresForm.selectStatus = []
  240. this.$refs.corresForm.leftLoading = true
  241. this.$refs.corresForm.rightLoading = true
  242. // 文件库字段
  243. FetchInitDocumentFieldByPid({ documentId: documentId, isType: 2 }).then((res) => {
  244. this.$refs.corresForm.options = res.sort((a, b) => {
  245. if (a.isInput !== b.isInput) {
  246. return a.isInput ? -1 : 1
  247. } else {
  248. return a.isSequence - b.isSequence
  249. }
  250. })
  251. this.$refs.corresForm.leftLoading = false
  252. })
  253. // 门类字段
  254. FetchInitCategoryFieldByPid({ categoryId: categoryId, isType: 2 }).then((res) => {
  255. this.$refs.corresForm.targetData = res.sort((a, b) => {
  256. if (a.isInput !== b.isInput) {
  257. return a.isInput ? -1 : 1
  258. } else {
  259. return a.isSequence - b.isSequence
  260. }
  261. })
  262. res.forEach((item, index) => {
  263. this.$refs.corresForm.selectStatus.push({ mode: true, value: '', field: item, isInput: item.isInput })
  264. })
  265. this.$refs.corresForm.rightLoading = false
  266. })
  267. },
  268. // table - 双击查看详情
  269. tableDoubleClick(row) {
  270. this.getInitDetail(row.id)
  271. },
  272. getInitDetail(id) {
  273. crudFieldMate.FetchInitFieldMate({ 'id': id }).then((res) => {
  274. this.$refs.detail.detailVisible = true
  275. this.$refs.detail.detailData = res
  276. }).catch(err => {
  277. console.log(err)
  278. })
  279. },
  280. toEdit(row) {
  281. this.$refs.corresForm.leftLoading = true
  282. this.$refs.corresForm.rightLoading = true
  283. this.$refs.corresForm.selectStatus = []
  284. FetchInitDocumentField({ documentId: row.document_id, isType: 2 }).then((res) => {
  285. this.$refs.corresForm.options = res.sort((a, b) => {
  286. if (a.isInput !== b.isInput) {
  287. return a.isInput ? -1 : 1
  288. } else {
  289. return a.isSequence - b.isSequence
  290. }
  291. })
  292. this.$refs.corresForm.leftLoading = false
  293. this.$nextTick(() => {
  294. this.$refs.corresForm.title = '编辑对应关系'
  295. this.$refs.corresForm.corresVisible = true
  296. this.$nextTick(() => {
  297. this.editGetMate(row.id)
  298. })
  299. })
  300. })
  301. // 门类字段
  302. FetchInitCategoryField({ categoryId: row.category_id, isType: 2 }).then((res) => {
  303. this.$refs.corresForm.targetData = res.sort((a, b) => {
  304. if (a.isInput !== b.isInput) {
  305. return a.isInput ? -1 : 1
  306. } else {
  307. return a.isSequence - b.isSequence
  308. }
  309. })
  310. res.forEach((item, index) => {
  311. this.$refs.corresForm.selectStatus.push({ mode: true, value: '', field: item, isInput: item.isInput })
  312. })
  313. this.$refs.corresForm.rightLoading = false
  314. })
  315. },
  316. editGetMate(id) {
  317. crudFieldMate.FetchInitFieldMate({ id: id }).then((res) => {
  318. this.$refs.corresForm.cuform.id = res.id
  319. this.$refs.corresForm.cuform.ruleName = res.ruleName
  320. this.$refs.corresForm.documentName = res.documentName
  321. this.$refs.corresForm.categoryName = res.categoryName
  322. this.$refs.corresForm.cuform.documentId = res.fieldMateDetails[0].pid.documentId.pid
  323. this.$refs.corresForm.cuform.categoryId = res.fieldMateDetails[0].pid.categoryId.pid
  324. const getIndexByCategory = (categoryFieldId) => {
  325. return this.$refs.corresForm.targetData.findIndex(item => item.fieldCnName === categoryFieldId)
  326. }
  327. res.fieldMateDetails.map(item => {
  328. const index = getIndexByCategory(item.categoryFieldId.fieldCnName)
  329. this.$refs.corresForm.selectStatus.splice(index, 1, { mode: false, value: item.documentFieldId.fieldCnName, field: item.documentFieldId, isInput: item.documentFieldId.isInput })
  330. })
  331. }).catch(err => {
  332. console.log(err)
  333. })
  334. },
  335. doExport(data) {
  336. console.log(data)
  337. crud.downloadLoading = true
  338. this.$confirm('此操作将导出所选数据' + '<span>你是否还要继续?</span>', '提示', {
  339. confirmButtonText: '继续',
  340. cancelButtonText: '取消',
  341. type: 'warning',
  342. dangerouslyUseHTMLString: true
  343. }).then(() => {
  344. const ids = []
  345. data.forEach(val => {
  346. ids.push(val.id)
  347. })
  348. const params = {
  349. 'fieldMates': ids
  350. }
  351. exportFile(this.baseApi + '/api/fieldMate/download?' + qs.stringify(params, { indices: false }))
  352. }).catch(() => {
  353. })
  354. },
  355. normalizer(node) {
  356. if (node.children && !node.children.length) {
  357. delete node.children
  358. }
  359. return {
  360. id: node.id,
  361. label: node.cnName,
  362. children: node.children,
  363. isDisabled: node.isType !== 2
  364. }
  365. }
  366. }
  367. }
  368. </script>
  369. <style lang="scss" scoped>
  370. .head-search{
  371. .vue-treeselect{
  372. font-size: 12px;
  373. }
  374. }
  375. </style>