فهرست منبع

form-tree-select

zhuangyunsheng 1 ماه پیش
والد
کامیت
aea985e776

+ 3 - 4
.env.development

@@ -7,12 +7,11 @@ VUE_APP_TITLE = EasyDo智能生产运营平台
 # 接口地址
 VUE_APP_ZEROAPI_BASEURL = http://www.qdeasydo.com
 # VUE_APP_MES_BASEURL = http://www.qdeasydo.com/mes
-# VUE_APP_MES_BASEURL = http://192.168.101.93:8200
-VUE_APP_MES_BASEURL = http://192.168.101.93:8080  #go
+VUE_APP_MES_BASEURL = http://192.168.101.93:8200
+# VUE_APP_MES_BASEURL = http://192.168.101.93:8080  #go
 
 # 本地端口
-# VUE_APP_PORT = 4400
-VUE_APP_PORT = 1200
+VUE_APP_PORT = 4400
 
 # 是否开启代理
 VUE_APP_PROXY = true

+ 21 - 2
src/components/scTable/helper.js

@@ -22,6 +22,7 @@ export const mapFormItemInput = (field, title, config = {}) => ({
  * @param field 字段
  * @param title 标题
  * @param config 其他配置
+ * @param config.props.type select/treeSelect
  */
 export const mapFormItemSelect = (field, title, config = {}) => ({
     field,
@@ -29,7 +30,25 @@ export const mapFormItemSelect = (field, title, config = {}) => ({
     titlePrefix: { content: title, icon: "vxe-icon-question-circle-fill" },
     itemRender: {
         name: "$form-select",
-        props: { popperClass: "vxe-table-slot--popper", filterable: true, clearable: true, placeholder: `请选择${title}`, ...XEUtils.pick(config, "props") },
+        props: { popperClass: "vxe-table-slot--popper", type: "select", filterable: true, clearable: true, placeholder: `请选择${title}`, ...XEUtils.get(config, "props", {}) },
+        ...XEUtils.omit(config, "props")
+    },
+    ...XEUtils.omit(config, "props")
+})
+
+/**
+ * 单选配置
+ * @param field 字段
+ * @param title 标题
+ * @param config 其他配置
+ */
+export const mapFormItemRadio = (field, title, config = {}) => ({
+    field,
+    title,
+    titlePrefix: { content: title, icon: "vxe-icon-question-circle-fill" },
+    itemRender: {
+        name: "$form-radio",
+        props: XEUtils.get(config, "props", {}), // disabled/readonly/strict(选中后取消)
         ...XEUtils.omit(config, "props")
     },
     ...XEUtils.omit(config, "props")
@@ -53,7 +72,7 @@ export const mapFormItemDatePicker = (field, title, config = {}) => ({
             valueFormat: "YYYY-MM-DD HH:mm:ss",
             placeholder: `请选择${title}`,
             defaultTime: XEUtils.get(config, "props.type")?.includes("range") ? [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)] : new Date(2000, 1, 1, 23, 59, 59),
-            ...XEUtils.get(config, "props")
+            ...XEUtils.get(config, "props", {})
         },
         ...XEUtils.omit(config, "props")
     },

+ 19 - 0
src/components/scTable/renderer/form-radio.vue

@@ -0,0 +1,19 @@
+<template>
+    <vxe-radio-group v-model="modelValue" :options="options" :option-props="optionProps" v-bind="renderOpts.props" @change="compChange"></vxe-radio-group>
+</template>
+
+<script setup>
+import XEUtils from "xe-utils";
+import config from "@/config/select";
+
+const props = defineProps({
+    renderOpts: { type: Object, default: () => ({}) },
+    params: { type: Object, default: () => ({}) }
+});
+
+const modelValue = ref(XEUtils.get(props.params.data, props.params.field, null));
+const options = ref(props.renderOpts.options || []);
+const optionProps = reactive(props.renderOpts.optionProps || config.props);
+
+const compChange = () => props.renderOpts.events.change({ [props.params.field]: modelValue.value });
+</script>

+ 3 - 1
src/components/scTable/renderer/form-select.vue

@@ -1,7 +1,9 @@
 <template>
-    <el-select v-model="modelValue" :loading="loading" v-bind="renderOpts.props" @change="compChange">
+    <el-select v-if="renderOpts.props.type == 'select'" :loading="loading" v-model="modelValue" v-bind="renderOpts.props" @change="compChange">
         <el-option v-for="(item, index) in options" :key="index" :label="XEUtils.get(item, optionProps.label, item)" :value="XEUtils.get(item, optionProps.value, index)"></el-option>
     </el-select>
+    
+    <el-tree-select v-if="renderOpts.props.type == 'treeSelect'" :loading="loading" v-model="modelValue" :nodeKey="optionProps.value" :data="options" :props="optionProps" checkStrictly v-bind="renderOpts.props" @change="compChange"></el-tree-select>
 </template>
 
 <script setup>

+ 2 - 1
src/config/select.js

@@ -17,6 +17,7 @@ export default {
     
 	props: {
 		label: "label",					// 映射label显示字段
-		value: "value"					// 映射value值字段
+		value: "value",					// 映射value值字段
+        disabled: "disabled"
 	}
 }

+ 7 - 0
src/vxeTable.js

@@ -14,6 +14,7 @@ localStorage.getItem("APP_DARK") && VxeUITable.VxeUI.setTheme("dark");
 // 自定义renderer
 import tableSearch from "@/components/scTable/renderer/table-search";
 import formSelect from "@/components/scTable/renderer/form-select";
+import formRadio from "@/components/scTable/renderer/form-radio";
 import cellTag from "@/components/scTable/renderer/cell-tag";
 
 VxeUI.renderer.mixin({
@@ -29,6 +30,12 @@ VxeUI.renderer.mixin({
         }
     },
 
+    "$form-radio": {
+        renderFormItemContent(renderOpts, params) {
+            return h(formRadio, { renderOpts, params });
+        }
+    },
+
     "$cell-tag": {
         renderTableCell(renderOpts, params) {
             const field = XEUtils.get(params, "column.field")