|
|
@@ -0,0 +1,106 @@
|
|
|
+<!--
|
|
|
+ * @Descripttion: 文件修订选择文件类型
|
|
|
+ * @version: 1.0
|
|
|
+ * @Author: Liu_jiaYin
|
|
|
+ * @Date: 2024-04-01 15:45:19
|
|
|
+ * @LastEditors: Do not edit
|
|
|
+ * @LastEditTime: 2024-04-24 17:59:45
|
|
|
+-->
|
|
|
+<template>
|
|
|
+ <el-cascader ref="cascader" v-model="cascaderData" :disabled="readonly" :options="options" :props="props" @change="handleChange">
|
|
|
+ <template slot-scope="{ node, data }">
|
|
|
+ <span>{{ data.name_ }}</span>
|
|
|
+ <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
|
|
|
+ </template>
|
|
|
+ </el-cascader>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
|
|
|
+import Json from '@/business/platform/serv/components/json.vue'
|
|
|
+import TreeUtils from '@/utils/tree'
|
|
|
+
|
|
|
+export default {
|
|
|
+ props: {
|
|
|
+ value: { // value
|
|
|
+ type: [String, Number, Object, Array],
|
|
|
+ default () {
|
|
|
+ return this.multiple ? [] : {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 所有字段数据,(包含主主子表)
|
|
|
+ formData: [Object, Array],
|
|
|
+ field: {
|
|
|
+ type: Object,
|
|
|
+ required: true
|
|
|
+ },
|
|
|
+ readonly: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ readonlyStyle: {
|
|
|
+ type: String,
|
|
|
+ default: 'text'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ props: {
|
|
|
+ value: 'ID_', label: 'name_', children: 'children'
|
|
|
+ },
|
|
|
+ cascaderData: [],
|
|
|
+ options: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ value: {
|
|
|
+ handler (val, oldVal) {
|
|
|
+ if (val) {
|
|
|
+ if (typeof val === 'string') {
|
|
|
+ this.cascaderData = val.split(',')
|
|
|
+ } else {
|
|
|
+ this.cascaderData = val
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.cascaderData = []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async created () {
|
|
|
+ await this.getCascaderOptions()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleChange (v) {
|
|
|
+ const nodesInfo = this.$refs['cascader'].getCheckedNodes()[0]
|
|
|
+ const wenJianXiLeiArrs = nodesInfo.pathNodes.map((item) => item.label)
|
|
|
+ // 组件本身字段的回填值
|
|
|
+ this.$emit('update:value', nodesInfo.path.join(','))
|
|
|
+ this.$emit('change-data', 'wenJianLeiXing', wenJianXiLeiArrs.join('/'))
|
|
|
+ this.$emit('change-data', 'leiXingId', nodesInfo.value)
|
|
|
+ },
|
|
|
+ // 获取文件分类信息
|
|
|
+ async getCascaderOptions () {
|
|
|
+ const sql = `select *FROM ibps_cat_type where category_key_ ='FILE_TYPE' ORDER BY sn_ ASC`
|
|
|
+ curdPost('sql', sql).then((res) => {
|
|
|
+ if (res.state === 200) {
|
|
|
+ const datas = res.variables.data
|
|
|
+ this.sqlDatas = datas
|
|
|
+ if (datas.length > 0) {
|
|
|
+ this.options = this.toTree(datas)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ toTree (data) {
|
|
|
+ return TreeUtils.transformToTreeFormat(data, {
|
|
|
+ idKey: 'ID_',
|
|
|
+ pIdKey: 'PARENT_ID_',
|
|
|
+ childrenKey: 'children'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped></style>
|