sr 4 tahun lalu
induk
melakukan
4deb899b36

+ 89 - 52
ruoyi-ui/src/components/DynamicForms/index.vue

@@ -1,11 +1,11 @@
 <template>
   <el-form-item label-width="120px" :label="formConfig.columnComment" style="display: inline-block;" :prop="formConfig.columnName">
     <!-- 输入框 -->
-    <el-input v-if="formConfig.htmlType == 'input'" v-model="config[formConfig.columnName]" :placeholder="'请输入'+formConfig.columnComment"
-      clearable @keyup.enter.native="handleQuery"  :disabled="formConfig.disabshow" />
+    <el-input v-if="formConfig.htmlType == 'input'" @change="iChange" v-model="config[formConfig.columnName]" :placeholder="'请输入'+formConfig.columnComment"
+      clearable @keyup.enter.native="handleQuery" :disabled="formConfig.disabshow" />
     <!-- 多行输入框 -->
     <el-input v-if="formConfig.htmlType == 'textarea'" type="textarea" v-model="config[formConfig.columnName]"
-      :placeholder="'请输入'+formConfig.columnComment" clearable @keyup.enter.native="handleQuery" :disabled="formConfig.disabshow"/>
+      :placeholder="'请输入'+formConfig.columnComment" clearable @keyup.enter.native="handleQuery" :disabled="formConfig.disabshow" />
     <!-- 下拉框 -->
     <el-select v-model="config[formConfig.columnName]" v-if="formConfig.htmlType == 'select'&&(!formConfig.fkInfo)"
       filterable :placeholder="'请输入'+formConfig.columnComment" :disabled="formConfig.disabshow">
@@ -13,10 +13,11 @@
         :value="itemChild.dictValue">
       </el-option>
     </el-select>
-    <!-- 下拉框搜索 -->
+    <!-- 下拉框搜索 -->
     <el-select :disabled="formConfig.disabshow" v-model="config[formConfig.columnName]" v-if="formConfig.htmlType == 'select'&&(formConfig.fkInfo)"
-      filterable remote :remote-method="remoteMethod" :loading="loading" :placeholder="'请输入'+formConfig.columnComment">
-      <el-option v-for="itemChild in filterList" :key="itemChild[formConfig.fkInfo.fkColumnName]" :label="itemChild[formConfig.fkInfo.dkColumnName]" :value="itemChild[formConfig.fkInfo.fkColumnName]">
+      filterable remote :remote-method="remoteMethod" :loading="loading" :placeholder="'请输入'+formConfig.columnComment">
+      <el-option v-for="itemChild in filterList" :key="itemChild[formConfig.fkInfo.fkColumnName]" :label="itemChild[formConfig.fkInfo.dkColumnName]"
+        :value="itemChild[formConfig.fkInfo.fkColumnName]">
       </el-option>
     </el-select>
     <!-- 复选框 -->
@@ -31,27 +32,28 @@
       <el-radio v-for="itemChild in formConfig.sysDictData" :key="itemChild.dictValue" :label="itemChild.dictValue">{{itemChild.dictLabel}}</el-radio>
     </el-radio-group>
     <!-- 时间控件 -->
-    <el-date-picker :disabled="formConfig.disabshow" v-model="config[formConfig.columnName]" v-if="formConfig.htmlType == 'datetime'" type="date"
-      :placeholder="'请输入'+formConfig.columnComment">
+    <el-date-picker :disabled="formConfig.disabshow" v-model="config[formConfig.columnName]" v-if="formConfig.htmlType == 'datetime'"
+      type="date" :placeholder="'请输入'+formConfig.columnComment">
     </el-date-picker>
     <!-- 上传图片 -->
-    <el-upload :disabled="formConfig.disabshow" v-if="formConfig.htmlType == 'imageUpload'" :headers="{Authorization: 'Bearer ' + getToken()}" :action="process + '/boman-file/upload'"
-      :file-list="config" list-type="picture-card" :on-preview="handlePictureCardPreview" :on-success="upImageFn"
-      :on-remove="reseImage">
+    <el-upload :disabled="formConfig.disabshow" v-if="formConfig.htmlType == 'imageUpload'" :headers="{Authorization: 'Bearer ' + getToken()}"
+      :action="process + '/boman-file/upload'" :file-list="config" list-type="picture-card" :on-preview="handlePictureCardPreview"
+      :on-success="upImageFn" :on-remove="reseImage">
       <i class="el-icon-plus"></i>
     </el-upload>
     <el-dialog :disabled="formConfig.disabshow" :visible.sync="dialogVisible" v-if="formConfig.htmlType == 'imageUpload'">
       <img :src="dialogImageUrl" alt="">
     </el-dialog>
     <!-- 上传文件 -->
-    <el-upload :disabled="formConfig.disabshow" class="upload-demo" :headers="{Authorization: 'Bearer ' + getToken()}" v-if="formConfig.htmlType == 'fileUpload'"
-      :action="process + '/boman-file/upload'" :on-change="handleChange" :on-success="upImageFn" :on-remove="reseImage"
-      :file-list="config">
+    <el-upload :disabled="formConfig.disabshow" class="upload-demo" :headers="{Authorization: 'Bearer ' + getToken()}"
+      v-if="formConfig.htmlType == 'fileUpload'" :action="process + '/boman-file/upload'" :on-change="handleChange"
+      :on-success="upImageFn" :on-remove="reseImage" :file-list="config">
       <el-button size="small" type="primary">点击上传</el-button>
       <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
     </el-upload>
     <!-- 富文本 -->
-    <editor :disabled="formConfig.disabshow" v-model="config[formConfig.columnName]" v-if="formConfig.htmlType == 'editor'" :min-height="192" />
+    <editor :disabled="formConfig.disabshow" v-model="config[formConfig.columnName]" v-if="formConfig.htmlType == 'editor'"
+      :min-height="192" />
   </el-form-item>
 </template>
 
@@ -90,45 +92,79 @@
     components: {
       Editor
     },
-    props: {
+    props: {
+      queryData: {
+        type: Object,
+        default: res => {
+          return {
+            showData: []
+          }
+        }
+      },
       formConfig: {
         type: Object,
         required: true,
-        'default': {
-          sysDictData: []
+        default: res => {
+          return {
+            sysDictData: []
+          }
         }
-      },
+      },
       type: {
         type: Number,
         default: 1
       },
     },
     created() {
-      this.config = {}
-      if(this.type){
-        if(this.formConfig.readonly == true){
-          this.formConfig.disabshow = true
-        }else if(this.formConfig.mask.slice(3,4) == '0' || this.formConfig.isonliy == true){
-          this.formConfig.disabshow = true
-        }else{
-          this.formConfig.disabshow = false
-        }
-        if(this.formConfig.fkInfo == null){
-          this.formConfig.fkInfo=false
-        }
-      }
-      this.init()
-    },
-    watch: {
-      'config': {
-         handler: function() {
-             this.$emit('modelFn',this.formConfig.columnName,this.config[this.formConfig.columnName])
-         },
-         deep: true
-     }
+      this.config = {}
+      if (this.type) {
+        if (this.formConfig.readonly == true) {
+          this.formConfig.disabshow = true
+        } else if (this.formConfig.mask.slice(3, 4) == '0' || this.formConfig.isonliy == true) {
+          this.formConfig.disabshow = true
+        } else {
+          this.formConfig.disabshow = false
+        }
+        if (this.formConfig.fkInfo == null) {
+          this.formConfig.fkInfo = false
+        }
+      }
+      this.init()
+      if (this.formConfig.extendedAttributes) {
+        let extend = JSON.parse(this.formConfig.extendedAttributes)
+        this.extFn(extend.col, extend.comp)
+      }
+    },
+    watch: {
+      'config': {
+        handler: function() {
+          this.$emit('modelFn', this.formConfig.columnName, this.config[this.formConfig.columnName])
+        },
+        deep: true
+      },
+      'queryData': {
+        handler: function() {
+          if (this.formConfig.extendedAttributes) {
+            let extend = JSON.parse(this.formConfig.extendedAttributes)
+            this.extFn(extend.col, extend.comp)
+          }
+        },
+        deep: true
+      },
     },
     mounted() {},
-    methods: {
+    methods: {
+      iChange(val){
+        this.$emit('iChange',this.formConfig.columnName,val)
+      },
+      extFn(col, comp) {
+        let str = this.getDyn(col, this.queryData.showData,comp)
+        this.config[this.formConfig.columnName] = this.eval(str)
+      },
+      eval(code){
+        let fun = new Function(`return ${code}`)();
+        return fun
+      },
       listIndexfouFn() {
         listIndexfou(this.aliemg).then(response => {
           if (response.data) {
@@ -154,15 +190,16 @@
           'fileUpload') {
           this.config = []
         } else {
-          this.$set(this.config, this.formConfig.columnName, ((this.formConfig.columnValue?this.formConfig.columnValue:this.formConfig.defaultValue) || ''))
-        }
-
-        if(this.formConfig.fkInfo){
-          this.aliemg.table = this.formConfig.fkInfo.fkTableName
-          if(this.formConfig.fkInfo.value){
-            this.aliemg.fixedData.condition[this.formConfig.fkInfo.dkColumnName] = this.formConfig.fkInfo.value
-          }
-          this.listIndexfouFn()
+          this.$set(this.config, this.formConfig.columnName, ((this.formConfig.columnValue ? this.formConfig.columnValue :
+            this.formConfig.defaultValue) || ''))
+        }
+
+        if (this.formConfig.fkInfo) {
+          this.aliemg.table = this.formConfig.fkInfo.fkTableName
+          if (this.formConfig.fkInfo.value) {
+            this.aliemg.fixedData.condition[this.formConfig.fkInfo.dkColumnName] = this.formConfig.fkInfo.value
+          }
+          this.listIndexfouFn()
         }
       },
       handleChange(file, fileList) {
@@ -197,7 +234,7 @@
           }
         }
       },
-      handlePictureCardPreview(file) {
+      handlePictureCardPreview(file) {
         console.log(file)
         this.dialogImageUrl = file.url;
         this.dialogVisible = true;

+ 3 - 1
ruoyi-ui/src/main.js

@@ -17,6 +17,7 @@ import store from './store'
 import router from './router'
 import permission from './directive/permission'
 import { download } from '@/utils/request'
+import { getDyn } from '@/utils/currencyFn'
 
 import '@/utils/dateApi'
 
@@ -46,7 +47,8 @@ Vue.prototype.resetForm = resetForm
 Vue.prototype.addDateRange = addDateRange
 Vue.prototype.selectDictLabel = selectDictLabel
 Vue.prototype.selectDictLabels = selectDictLabels
-Vue.prototype.download = download
+Vue.prototype.download = download
+Vue.prototype.getDyn = getDyn
 Vue.prototype.handleTree = handleTree
 
 Vue.prototype.msgSuccess = function (msg) {

+ 13 - 9
ruoyi-ui/src/views/system/table/index.vue

@@ -19,7 +19,7 @@
           <el-collapse-item :title="item.columnComment" :name="index" v-for="(item,index) in queryData.showData" :key="index">
             <el-row>
               <el-col :span="24" :key="index">
-                <dynamic-forms @modelFn="modelFn" :ref="items.columnName" :config="queryParams" @inputs="changeFn" :formConfig="items" v-for="(items,indexs) in item.hrChildren"
+                <dynamic-forms @iChange="iChange" :queryData="queryData" @modelFn="modelFn" :ref="items.columnName" :config="queryParams" @inputs="changeFn" :formConfig="items" v-for="(items,indexs) in item.hrChildren"
                   :key='indexs' />
               </el-col>
             </el-row>
@@ -108,14 +108,20 @@
       if(this.$route.query.tabfe){
        this.tablees = this.$route.query.tabfe
        this.juegkae = this.$route.query.tables + '_id'
-
-       console.log(this.juegkae)
-      }
-      console.log(this.forme.fixedData)
+      }
       this.init()
       // this.tablsie()
     },
-    methods: {
+    methods: {
+      iChange(name,val){
+        for(let item of this.queryData.showData){
+          for(let itemChild of item.hrChildren){
+            if(itemChild.columnName == name){
+              itemChild.columnValue = (val-0)
+            }
+          }
+        }
+      },
       modelFn(obj, cont) {
         this.$set(this.queryParams,obj,cont)
       },
@@ -182,13 +188,11 @@
           this.reload()
         } else if (index == '返回') {
           this.$store.dispatch("tagsView/delView", this.$route);
-            this.$router.go(-1)
+          this.$router.go(-1)
         } else if (index == '刷新') {
           this.xidugje = 1
           this.reload()
         }
-
-
         // this.getList();
       },
       getList() {