SpringSunYY 5 месяцев назад
Родитель
Сommit
7943313079
2 измененных файлов с 137 добавлено и 39 удалено
  1. 36 10
      ruoyi_generator/vm/vue/index-tree.vue.vm
  2. 101 29
      ruoyi_generator/vm/vue/index.vue.vm

+ 36 - 10
ruoyi_generator/vm/vue/index-tree.vue.vm

@@ -94,7 +94,7 @@
 
     <el-table
       v-if="refreshTable"
-      v-loading="loading"
+      :loading="loading"
       :data="{{ table.business_name }}List"
       row-key="{% if table.tree_code %}{{ table.tree_code }}{% else %}id{% endif %}"
       :default-expand-all="isExpandAll"
@@ -552,7 +552,11 @@ export default {
         this.form = response.data;
 {%- for column in table.columns %}
 {%- if column.html_type == 'checkbox' %}
-        this.form.{{ underscore(column.java_field) }} = this.form.{{ underscore(column.java_field) }}.split(",");
+        if (this.form.{{ underscore(column.java_field) }}) {
+          this.form.{{ underscore(column.java_field) }} = this.form.{{ underscore(column.java_field) }}.split(",");
+        } else {
+          this.form.{{ underscore(column.java_field) }} = [];
+        }
 {%- endif %}
 {%- endfor %}
         this.open = true;
@@ -563,19 +567,15 @@ export default {
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
-{%- for column in table.columns %}
-{%- if column.html_type == 'checkbox' %}
-          this.form.{{ underscore(column.java_field) }} = this.form.{{ underscore(column.java_field) }}.join(",");
-{%- endif %}
-{%- endfor %}
-          if (this.form.{% if table.pk_column %}{{ underscore(table.pk_column.java_field) }}{% else %}id{% endif %} != null) {
-            update{{ ApiName }}(this.form).then(response => {
+          const submitData = this.buildSubmitData();
+          if (submitData.{% if table.pk_column %}{{ underscore(table.pk_column.java_field) }}{% else %}id{% endif %} != null) {
+            update{{ ApiName }}(submitData).then(response => {
               this.$modal.msgSuccess("修改成功");
               this.open = false;
               this.getList();
             });
           } else {
-            add{{ ApiName }}(this.form).then(response => {
+            add{{ ApiName }}(submitData).then(response => {
               this.$modal.msgSuccess("新增成功");
               this.open = false;
               this.getList();
@@ -584,6 +584,32 @@ export default {
         }
       });
     },
+    buildSubmitData() {
+      const data = { ...this.form };
+{%- for column in table.columns %}
+{%- if column.html_type == 'checkbox' %}
+      if (Array.isArray(data.{{ underscore(column.java_field) }})) {
+        data.{{ underscore(column.java_field) }} = data.{{ underscore(column.java_field) }}.join(",");
+      } else if (data.{{ underscore(column.java_field) }}) {
+        data.{{ underscore(column.java_field) }} = String(data.{{ underscore(column.java_field) }});
+      }
+{%- endif %}
+{%- if column.java_type in ['Integer', 'Long', 'Short'] %}
+      if (data.{{ underscore(column.java_field) }} !== null && data.{{ underscore(column.java_field) }} !== undefined && data.{{ underscore(column.java_field) }} !== "") {
+        data.{{ underscore(column.java_field) }} = parseInt(data.{{ underscore(column.java_field) }}, 10);
+      } else {
+        data.{{ underscore(column.java_field) }} = null;
+      }
+{%- elif column.java_type in ['Float', 'Double', 'BigDecimal', 'Decimal'] %}
+      if (data.{{ underscore(column.java_field) }} !== null && data.{{ underscore(column.java_field) }} !== undefined && data.{{ underscore(column.java_field) }} !== "") {
+        data.{{ underscore(column.java_field) }} = parseFloat(data.{{ underscore(column.java_field) }});
+      } else {
+        data.{{ underscore(column.java_field) }} = null;
+      }
+{%- endif %}
+{%- endfor %}
+      return data;
+    },
     /** 删除按钮操作 */
     handleDelete(row) {
       this.$modal.confirm('是否确认删除{{ table.function_name }}编号为"' + row.{% if table.pk_column %}{{ underscore(table.pk_column.java_field) }}{% else %}id{% endif %} + '"的数据项?').then(function() {

+ 101 - 29
ruoyi_generator/vm/vue/index.vue.vm

@@ -102,45 +102,77 @@
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
     </el-row>
 
-    <el-table v-loading="loading" :data="{{ table.business_name }}List" @selection-change="handleSelectionChange">
+    <el-table :loading="loading" :data="{{ table.business_name }}List" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
-{%- for column in table.columns %}
-{%- if column.is_list %}
-  {%- if column.is_pk %}
-      <el-table-column label="{{ column.column_comment }}" align="center" v-if="columns[{{ column.list_index }}].visible" prop="{{ column.java_field }}" >
+      {%- for column in table.columns %}
+      {%- set java_field = column.java_field %}
+      {%- set comment = column.column_comment %}
+      {%- if '(' in comment or '(' in comment %}
+      {%- if '(' in comment %}
+      {%- set comment = comment.split('(')[0] %}
+      {%- elif '(' in comment %}
+      {%- set comment = comment.split('(')[0] %}
+      {%- endif %}
+      {%- endif %}
+      {%- if column.is_pk == '1' %}
+      {%- elif column.is_list and column.list_index is not none and column.html_type == 'datetime' %}
+      <el-table-column label="{{ comment }}" align="center" v-if="columns[{{ column.list_index }}].visible" prop="{{ java_field }}" width="180">
         <template slot-scope="scope">
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-view"
-            @click="handleView(scope.row)"
-            v-hasPermi="['{{ table.module_name }}:{{ table.business_name }}:query']"
-          >{{ column.column_comment }}</el-button>
+          <span>{{ "{{ parseTime(scope.row." }}{{ java_field }}{{ ", '{y}-{m}-{d}') }}" }}</span>
         </template>
       </el-table-column>
-  {%- elif column.html_type == 'imageUpload' %}
-      <el-table-column label="{{ column.column_comment }}" align="center" v-if="columns[{{ column.list_index }}].visible" prop="{{ column.java_field }}" width="100">
+      {%- elif column.is_list and column.list_index is not none and column.html_type == 'imageUpload' %}
+      <el-table-column label="{{ comment }}" align="center" v-if="columns[{{ column.list_index }}].visible" prop="{{ java_field }}" width="100">
         <template slot-scope="scope">
-          <image-preview :src="scope.row.{{ underscore(column.java_field) }}" :width="50" :height="50"/>
+          <image-preview :src="scope.row.{{ java_field }}" :width="50" :height="50"/>
         </template>
       </el-table-column>
-  {%- elif column.dict_type != '' %}
-      <el-table-column label="{{ column.column_comment }}" align="center" v-if="columns[{{ column.list_index }}].visible" prop="{{ column.java_field }}">
+      {%- elif column.is_list and column.list_index is not none and column.html_type == 'fileUpload' %}
+      <el-table-column label="{{ comment }}" align="center" v-if="columns[{{ column.list_index }}].visible" prop="{{ java_field }}" width="100">
         <template slot-scope="scope">
-          <dict-tag :options="dict.type.{{ column.dict_type }}" :value="scope.row.{{ column.java_field }}" />
+          <div v-if="scope.row.{{ underscore(java_field) }}">
+            <el-tooltip placement="top" effect="light">
+              <div slot="content">
+                <div v-for="(file,index) in scope.row.{{ java_field }}.split(',')"
+                     :key="index"
+                     style="text-align: left;padding: 5px;">
+                  <el-link
+                      :download="getFileName(file)"
+                      :href="getFilePath(file)"
+                      :underline="false"
+                      target="_blank"
+                      style="font-size: 14px"
+                  >
+                    <span style="cursor: pointer;"> {{ "{{ getFileName(file) }}" }} </span>
+                  </el-link>
+                </div>
+              </div>
+              <span style="cursor: pointer; color: #409EFF;">查看文件</span>
+            </el-tooltip>
+          </div>
+          <div v-else>
+            -
+          </div>
         </template>
       </el-table-column>
-  {%- elif column.html_type == 'datetime' %}
-      <el-table-column label="{{ column.column_comment }}" align="center" v-if="columns[{{ column.list_index }}].visible" prop="{{ column.java_field }}" width="180">
+      {%- elif column.is_list and column.list_index is not none and column.dict_type and column.dict_type != '' %}
+      <el-table-column label="{{ comment }}" align="center" v-if="columns[{{ column.list_index }}].visible" prop="{{ java_field }}">
         <template slot-scope="scope">
-          <span>{{ "{{ scope.row." }}{{ column.java_field }}{{ " }}" }}</span>
+          {%- if column.html_type == 'checkbox' %}
+          <dict-tag :options="dict.type.{{ column.dict_type }}" :value="scope.row.{{ java_field }} ? scope.row.{{ java_field }}.split(',') : []"/>
+          {%- else %}
+          <dict-tag :options="dict.type.{{ column.dict_type }}" :value="scope.row.{{ java_field }}"/>
+          {%- endif %}
         </template>
       </el-table-column>
-  {%- else %}
-      <el-table-column label="{{ column.column_comment }}" align="center" v-if="columns[{{ column.list_index }}].visible" prop="{{ column.java_field }}" />
-  {%- endif %}
-{%- endif %}
-{%- endfor %}
+      {%- elif column.is_list and column.list_index is not none and java_field %}
+      {%- if column.list_index == 0 %}
+      <el-table-column label="{{ comment }}" :show-overflow-tooltip="true" v-if="columns[{{ column.list_index }}].visible" prop="{{ java_field }}" />
+      {%- else %}
+      <el-table-column label="{{ comment }}" align="center" :show-overflow-tooltip="true" v-if="columns[{{ column.list_index }}].visible" prop="{{ java_field }}" />
+      {%- endif %}
+      {%- endif %}
+      {%- endfor %}
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
@@ -420,7 +452,11 @@ export default {
     reset() {
       this.form = {
 {%- for column in table.columns %}
+{%- if column.html_type == 'checkbox' %}
+        {{ column.java_field }}: []{% if not loop.last %},{% endif %}
+{%- else %}
         {{ column.java_field }}: null{% if not loop.last %},{% endif %}
+{%- endif %}
 {%- endfor %}
       };
       this.resetForm("form");
@@ -459,6 +495,15 @@ export default {
       const {{ table.pk_column.java_field if table.pk_column }} = row.{{ table.pk_column.java_field if table.pk_column }} || this.ids
       get{{ ApiName }}({{ table.pk_column.java_field if table.pk_column }}).then(response => {
         this.form = response.data;
+{%- for column in table.columns %}
+{%- if column.html_type == 'checkbox' %}
+        if (this.form.{{ column.java_field }}) {
+          this.form.{{ column.java_field }} = this.form.{{ column.java_field }}.split(",");
+        } else {
+          this.form.{{ column.java_field }} = [];
+        }
+{%- endif %}
+{%- endfor %}
         this.open = true;
         this.title = "修改{{ table.function_name }}";
       });
@@ -467,14 +512,15 @@ export default {
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
-          if (this.form.{{ table.pk_column.java_field if table.pk_column }} != null) {
-            update{{ ApiName }}(this.form).then(response => {
+          const submitData = this.buildSubmitData();
+          if (submitData.{{ table.pk_column.java_field if table.pk_column }} != null) {
+            update{{ ApiName }}(submitData).then(response => {
               this.$modal.msgSuccess("修改成功");
               this.open = false;
               this.getList();
             });
           } else {
-            add{{ ApiName }}(this.form).then(response => {
+            add{{ ApiName }}(submitData).then(response => {
               this.$modal.msgSuccess("新增成功");
               this.open = false;
               this.getList();
@@ -522,6 +568,32 @@ export default {
       this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
       this.getList();
     },
+    buildSubmitData() {
+      const data = { ...this.form };
+{%- for column in table.columns %}
+{%- if column.html_type == 'checkbox' %}
+      if (Array.isArray(data.{{ column.java_field }})) {
+        data.{{ column.java_field }} = data.{{ column.java_field }}.join(",");
+      } else if (data.{{ column.java_field }}) {
+        data.{{ column.java_field }} = String(data.{{ column.java_field }});
+      }
+{%- endif %}
+{%- if column.java_type in ['Integer', 'Long', 'Short'] %}
+      if (data.{{ column.java_field }} !== null && data.{{ column.java_field }} !== undefined && data.{{ column.java_field }} !== "") {
+        data.{{ column.java_field }} = parseInt(data.{{ column.java_field }}, 10);
+      } else {
+        data.{{ column.java_field }} = null;
+      }
+{%- elif column.java_type in ['Float', 'Double', 'BigDecimal', 'Decimal'] %}
+      if (data.{{ column.java_field }} !== null && data.{{ column.java_field }} !== undefined && data.{{ column.java_field }} !== "") {
+        data.{{ column.java_field }} = parseFloat(data.{{ column.java_field }});
+      } else {
+        data.{{ column.java_field }} = null;
+      }
+{%- endif %}
+{%- endfor %}
+      return data;
+    },
     // 提交上传文件
     submitFileForm() {
       this.$refs.upload.submit();