Pārlūkot izejas kodu

Merge branch 'master' of http://36.137.93.232:3000/hf/byte-sailing-new

# Conflicts:
#	src/components/headerBar/header-bar.vue
asd26269546 2 gadi atpakaļ
vecāks
revīzija
cdace1dcd8

+ 342 - 0
src/components/iot/SelectProduct.vue

@@ -0,0 +1,342 @@
+<template>
+  <div class="tenant">
+    <!-- <Banner /> -->
+    <div class="content">
+      <byTable
+        :source="sourceList.data"
+        :pagination="sourceList.pagination"
+        :config="config"
+        :loading="loading"
+        highlight-current-row
+        :selectConfig="selectConfig"
+        :table-events="{
+          //element talbe事件都能传
+          select: select,
+        }"
+        @get-list="getList"
+      >
+        <template #slotName="{ item }">
+          {{ item.createTime }}
+        </template>
+      </byTable>
+    </div>
+    <el-dialog
+      :title="modalType == 'add' ? '添加产品' : '编辑'"
+      v-model="dialogVisible"
+      width="800"
+      v-loading="loading"
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="byform"
+      >
+      </byForm>
+      <template #footer>
+        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
+        <el-button
+          type="primary"
+          @click="submitForm('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+  
+<script setup>
+/* eslint-disable vue/no-unused-components */
+import { ElMessage, ElMessageBox } from "element-plus";
+import byTable from "@/components/byTable/index";
+import byForm from "@/components/byForm/index";
+import { computed, defineComponent, ref, toRaw } from "vue";
+const loading = ref(false);
+const submitLoading = ref(false);
+const sourceList = ref({
+  data: [],
+  pagination: {
+    total: 3,
+    pageNum: 1,
+    pageSize: 10,
+  },
+});
+let dialogVisible = ref(false);
+let roomDialogVisible = ref(false);
+let modalType = ref("add");
+let rules = ref({
+  tdaApplicationId: [
+    { required: true, message: "请选择行业名称", trigger: ["blur", "change"] },
+  ],
+  name: [
+    { required: true, message: "请输入产品名称", trigger: ["blur", "change"] },
+  ],
+  manufacturerName: [
+    { required: true, message: "请选择厂商名称", trigger: ["blur", "change"] },
+  ],
+  deviceType: [
+    { required: true, message: "请选择设备类型", trigger: ["blur", "change"] },
+  ],
+});
+const { proxy } = getCurrentInstance();
+const selectConfig = reactive([
+  {
+    label: "行业名称",
+    prop: "id",
+    data: [],
+  },
+  {
+    label: "厂商名称",
+    prop: "id",
+    data: [],
+  },
+]);
+const config = computed(() => {
+  return [
+    {
+      attrs: {
+        label: "行业名称",
+        prop: "appName",
+      },
+    },
+    {
+      attrs: {
+        label: "产品名称",
+        prop: "name",
+        align: "center",
+      },
+    },
+    {
+      attrs: {
+        label: "协议类型",
+        prop: "protocolType",
+        align: "center",
+      },
+    },
+    {
+      attrs: {
+        label: "数据格式",
+        prop: "dataFormat",
+        align: "center",
+      },
+    },
+    {
+      attrs: {
+        label: "厂商名称",
+        prop: "manufacturerName",
+        align: "center",
+      },
+    },
+    {
+      attrs: {
+        label: "设备类型",
+        prop: "deviceType",
+      },
+    },
+
+    {
+      attrs: {
+        label: "操作",
+        width: "100",
+        align: "right",
+      },
+      // 渲染 el-button,一般用在最后一列。
+      renderHTML(row) {
+        return [
+          {
+            attrs: {
+              label: "选择",
+              type: "primary",
+              text: true,
+            },
+            el: "button",
+            click() {
+              handleSelect(row);
+            },
+          },
+        ];
+      },
+    },
+  ];
+});
+
+let formData = reactive({
+  data: {},
+  treeData: [],
+});
+const formOption = reactive({
+  inline: true,
+  labelWidth: 100,
+  itemWidth: 100,
+  rules: [],
+});
+const byform = ref(null);
+const treeData = ref([]);
+const formConfig = reactive([
+  {
+    type: "select",
+    prop: "tdaApplicationId",
+    label: "行业名称",
+    required: true,
+    data: [
+      {
+        name: "aaa", //title || name 是显示的字段名称
+        value: "11", //value || id 是选择的字段值
+      },
+    ],
+  },
+  {
+    type: "input",
+    prop: "name",
+    label: "产品名称",
+    required: true,
+    itemWidth: 100,
+    itemType: "text",
+  },
+  {
+    type: "select",
+    prop: "protocolType",
+    label: "协议类型",
+    disabled: true,
+    required: true,
+  },
+  {
+    type: "select",
+    prop: "dataFormat",
+    label: "数据格式",
+    disabled: true,
+    required: true,
+  },
+  {
+    type: "input",
+    prop: "manufacturerName",
+    label: "厂商名称",
+    required: true,
+  },
+  {
+    type: "input",
+    prop: "deviceType",
+    label: "设备类型",
+    required: true,
+  },
+]);
+const getList = async (req) => {
+  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  loading.value = true;
+  proxy
+    .post("/tdaProduct/page", sourceList.value.pagination)
+    .then((message) => {
+      console.log(message);
+      sourceList.value.data = message.rows;
+      sourceList.value.pagination.total = message.total;
+      setTimeout(() => {
+        loading.value = false;
+      }, 200);
+    });
+};
+const openModal = () => {
+  dialogVisible.value = true;
+  modalType.value = "add";
+  formData.data = {
+    protocolType: "HTTP",
+    dataFormat: "JSON",
+  };
+};
+const selection = ref({
+  data: [],
+});
+const select = (_selection, row) => {
+  selection.value.data = _selection;
+  console.log(_selection.length);
+};
+const openRoomModal = () => {
+  roomDialogVisible.value = true;
+  proxy
+    .get("/tenantInfo/roleMenuTreeSelect/" + selection.value.data[0].tenantId)
+    .then((res) => {
+      if (res.code == 200) {
+        treeData.value = res.menus;
+        formData.treeData = res.checkedKeys;
+        tree.value.setCheckedKeys(res.checkedKeys);
+      }
+    });
+};
+const tree = ref(null);
+const submitTree = () => {
+  proxy
+    .post("/tenantInfo/bindingMenu", {
+      tenantId: selection.value.data[0].tenantId,
+      menuIdList: tree.value.getCheckedKeys(),
+    })
+    .then((res) => {
+      ElMessage({
+        message: "保存成功",
+        type: "success",
+      });
+      roomDialogVisible.value = false;
+    });
+};
+
+const submitForm = () => {
+  console.log(byform.value);
+  byform.value.handleSubmit((valid) => {
+    submitLoading.value = true;
+
+    proxy.post("/tdaProduct/" + modalType.value, formData.data).then(
+      (res) => {
+        ElMessage({
+          message: modalType.value == "add" ? "添加成功" : "编辑成功",
+          type: "success",
+        });
+        dialogVisible.value = false;
+        submitLoading.value = false;
+        getList();
+      },
+      (err) => (submitLoading.value = false)
+    );
+  });
+};
+
+const getDtl = (row) => {
+  modalType.value = "edit";
+  proxy.post("/tdaProduct/detail", { id: row.id }).then((res) => {
+    formData.data = res;
+    console.log(formData);
+    dialogVisible.value = true;
+  });
+};
+const selectData = reactive({
+  tradeList: [],
+});
+const getSelect = () => {
+  proxy
+    .post("/tdaApplication/page", { pageNum: 1, pageSize: 9999 })
+    .then((message) => {
+      selectData.tradeList = message.rows;
+      selectConfig[0].data = selectData.tradeList.map((x) => ({
+        label: x.appName,
+        value: x.id,
+      }));
+      formConfig[0].data = selectData.tradeList.map((x) => ({
+        title: x.appName,
+        value: x.id,
+      }));
+    });
+};
+
+getList();
+getSelect();
+const handleSelect = (row) => {
+  proxy.$emit("handleSelect", toRaw(row));
+};
+</script>
+  
+<style lang="scss" scoped>
+.tenant {
+  padding: 20px;
+}
+</style>

+ 1 - 1
src/layout/components/AppMain.vue

@@ -34,7 +34,7 @@ const tagsViewStore = useTagsViewStore()
 .hasTagsView {
   .app-main {
     /* 84 = navbar + tags-view = 50 + 34 */
-    min-height: calc(100vh - 84px);
+    min-height: calc(100vh - 100px);
   }
 
   .fixed-header + .app-main {

+ 1 - 1
src/layout/components/TagsView/ScrollPane.vue

@@ -99,7 +99,7 @@ defineExpose({
     bottom: 0px;
   }
   :deep(.el-scrollbar__wrap) {
-    height: 49px;
+    height: 50px;
   }
 }
 </style>

+ 26 - 27
src/layout/components/TagsView/index.vue

@@ -8,12 +8,13 @@
         :class="isActive(tag) ? 'active' : ''"
         :to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
         class="tags-view-item"
-        :style="activeStyle(tag)"
+        
         @click.middle="!isAffix(tag) ? closeSelectedTag(tag) : ''"
         @contextmenu.prevent="openMenu(tag, $event)"
       >
         {{ tag.title }}
-        <span v-if="!isAffix(tag)" @click.prevent.stop="closeSelectedTag(tag)">
+        <!-- v-if="!isAffix(tag)" -->
+        <span  style="margin-left:8px" @click.prevent.stop="closeSelectedTag(tag)">
           <close class="el-icon-close" style="width: 1em; height: 1em;vertical-align: middle;" />
         </span>
       </router-link>
@@ -86,7 +87,7 @@ function activeStyle(tag) {
   if (!isActive(tag)) return {};
   return {
     "background-color": theme.value,
-    "border-color": theme.value
+    "border-color": 'none'
   };
 }
 function isAffix(tag) {
@@ -243,45 +244,43 @@ function handleScroll() {
 
 <style lang='scss' scoped>
 .tags-view-container {
-  height: 34px;
+  height: 50px;
   width: 100%;
   background: #fff;
-  border-bottom: 1px solid #d8dce5;
-  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 0 3px 0 rgba(0, 0, 0, 0.04);
+  
   .tags-view-wrapper {
     .tags-view-item {
       display: inline-block;
       position: relative;
       cursor: pointer;
-      height: 26px;
-      line-height: 26px;
-      border: 1px solid #d8dce5;
-      color: #495060;
+      height: 50px;
+      line-height: 50px;
+      
+      color: #999999;
       background: #fff;
-      padding: 0 8px;
+      padding: 0 20px;
       font-size: 12px;
-      margin-left: 5px;
-      margin-top: 4px;
+      margin:0;
       &:first-of-type {
-        margin-left: 15px;
+        // margin-left: 15px;
       }
       &:last-of-type {
         margin-right: 15px;
       }
       &.active {
-        background-color: #42b983;
-        color: #fff;
-        border-color: #42b983;
-        &::before {
-          content: "";
-          background: #fff;
-          display: inline-block;
-          width: 8px;
-          height: 8px;
-          border-radius: 50%;
-          position: relative;
-          margin-right: 2px;
-        }
+        background-color: #D9EDFF!important;
+        color: #0084FF!important;
+        //border-color: #42b983;
+        // &::before {
+        //   content: "";
+        //   background: #fff;
+        //   display: inline-block;
+        //   width: 8px;
+        //   height: 8px;
+        //   border-radius: 50%;
+        //   position: relative;
+        //   margin-right: 2px;
+        // }
       }
     }
   }

+ 3 - 139
src/views/index.vue

@@ -1,12 +1,8 @@
 <template>
 	<div class="app-container home">
-		<byTableDemo></byTableDemo>
-		<div id="pdfDom" style="padding:20px">
-			
-			<div>啊是多久啊还是打卡机圣诞卡啊是多久啊还是打卡机圣诞卡啊是多久啊还是打卡机圣诞卡啊是多久啊还是打卡机圣诞卡啊是多久啊还是打卡机圣诞卡啊是多久啊还是打卡机圣诞卡啊是多久啊还是打卡机圣诞卡啊是多久啊还是打卡机圣诞卡啊是多久啊还是打卡机圣诞卡啊是多久啊还是打卡机圣诞卡啊是多久啊还是打卡机圣诞卡</div>
-			
-		</div>
-		<el-button @click="xiazai">xiazai</el-button>
+		<!-- <byTableDemo></byTableDemo> -->
+		
+		
 	</div>
 </template>
 
@@ -19,138 +15,6 @@ import JsPDF from 'jspdf'
 function goTarget(url) {
 	window.open(url, '__blank')
 }
-
-const pdfDoc = new JsPDF()
-// let pWidth = pdfDoc.internal.pageSize.width; // 595.28 is the width of a4
-// let srcWidth = element.scrollWidth;
-// let margin = 18; // narrow margin - 1.27 cm (36);
-// let scale = (pWidth - margin * 2) / srcWidth;
-// pdfDoc.html(element, {
-// 	x: 10,
-// 	y: 10,
-// 	html2canvas: {
-// 		scale: scale,
-// 	},
-// 	callback: function (doc) {
-// 		doc.save()
-// 	},
-// })
-
-const getPdf = (title) => {
-	// pdfDom 这个就是你vue页面中定义的ID  比如<div id="pdfDom">  这个也要避下雷
-	const element = document.getElementById('pdfDom')
-	console.log(element)
-	window.pageYoffset = 0
-	document.documentElement.scrollTop = 0
-	document.body.scrollTop = 0
-	setTimeout(() => {
-		const nowDate = new Date()
-		const date = {
-			year: nowDate.getFullYear(),
-			month: nowDate.getMonth() + 1,
-			date: nowDate.getDate(),
-			hours: nowDate.getHours(),
-			minutes: nowDate.getMinutes(),
-			seconds: nowDate.getSeconds(),
-		}
-		const newmonth = date.month > 10 ? date.month : '0' + date.month
-		const newday = date.date > 10 ? date.date : '0' + date.date
-		const newminutes = date.minutes < 10 ? '0' + date.minutes : date.minutes
-		const newseconds = date.seconds < 10 ? '0' + date.seconds : date.seconds
-		const value =
-			date.year + newmonth + newday + date.hours + newminutes + newseconds
-		let id = ''
-		//创建一个画布    ---  增加导出的pdf水印 !!
-		let can = document.createElement('canvas')
-		//设置画布的长宽
-		can.width = 400
-		can.height = 500
-
-		let cans = can.getContext('2d')
-		//旋转角度
-		cans.rotate((-15 * Math.PI) / 180)
-		cans.font = '18px Vedana'
-		//设置填充绘画的颜色、渐变或者模式
-		cans.fillStyle = 'rgba(200, 200, 200, 0.40)'
-		//设置文本内容的当前对齐方式
-		cans.textAlign = 'left'
-		//设置在绘制文本时使用的当前文本基线
-		cans.textBaseline = 'Middle'
-		//在画布上绘制填色的文本(输出的文本,开始绘制文本的X坐标位置,开始绘制文本的Y坐标位置)
-		//cans.fillText(value, can.width / 8, can.height / 2)
-		let div = document.createElement('div')
-
-		div.id = id
-		div.style.pointerEvents = 'none'
-		div.style.top = '20px'
-		div.style.left = '-20px'
-		div.style.position = 'fixed'
-		div.style.zIndex = '100000'
-		div.style.width = document.getElementById('pdfDom').scrollHeight + 'px'
-		div.style.height = document.getElementById('pdfDom').scrollHeight + 'px'
-		div.style.background =
-			'url(' + can.toDataURL('image/png') + ') left top repeat'
-		document.getElementById('pdfDom').appendChild(div) // 到页面中
-		console.log(html2canvas)
-		html2canvas(element, {
-			allowTaint: true,
-			useCORS: true, // 需要注意,element的 高度 宽度一定要在这里定义一下,不然会存在只下载了当前你能看到的页面   避雷避雷!!!
-			// scale: 2, // 提升画面质量,但是会增加文件大小
-			height: document.getElementById('pdfDom').scrollHeight,
-			windowHeight: document.getElementById('pdfDom').scrollHeight,
-		}).then(function (canvas) {
-			var contentWidth = canvas.width
-			var contentHeight = canvas.height
-			console.log('contentWidth', contentWidth)
-			console.log('contentHeight', contentHeight)
-			// 一页pdf显示html页面生成的canvas高度;
-			var pageHeight = (contentWidth * 841.89) / 592.28
-			// 未生成pdf的html页面高度
-			var leftHeight = contentHeight
-
-			console.log('pageHeight', pageHeight)
-			console.log('leftHeight', leftHeight)
-			// 页面偏移
-			var position = 0
-			// a4纸的尺寸[595.28,841.89],html页面生成的canvas在pdf中图片的宽高
-			var imgWidth = 595.28
-			var imgHeight = (592.28 / contentWidth) * contentHeight
-
-			var pageData = canvas.toDataURL('image/jpeg', 1.0)
-
-			var pdf = new JsPDF('', 'pt', 'a4')
-
-			// 有两个高度需要区分,一个是html页面的实际高度,和生成pdf的页面高度(841.89)
-			// 当内容未超过pdf一页显示的范围,无需分页
-			if (leftHeight < pageHeight) {
-				console.log('没超过1页')
-				pdf.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight)
-			} else {
-				while (leftHeight > 0) {
-					console.log('超过1页')
-					pdf.addImage(
-						pageData,
-						'JPEG',
-						0,
-						position,
-						imgWidth,
-						imgHeight
-					)
-					leftHeight -= pageHeight
-					position -= 841.89
-					// 避免添加空白页
-					if (leftHeight > 0) {
-						pdf.addPage()
-					}
-				}
-			}
-			pdf.save(title + '.pdf')
-		})
-	}, 1000)
-}
-const xiazai = (() => {
-	getPdf('xxxxx')
-})
 // ​
 onMounted(() => {
 	

+ 2 - 1
src/views/iot/base/equipment/index.vue

@@ -329,7 +329,8 @@ const submitForm = () => {
 };
 
 const getDtl = (row) => {
-  modalType = "edit";
+  modalType.value = "edit";
+
   proxy.post("/tdaDevice/detail", { id: row.id }).then((res) => {
     formData.data = res;
     console.log(formData);

+ 1 - 1
src/views/iot/base/product/index.vue

@@ -330,7 +330,7 @@ const submitForm = () => {
 };
 
 const getDtl = (row) => {
-  modalType = "edit";
+  modalType.value = "edit";
   proxy.post("/tdaProduct/detail", { id: row.id }).then((res) => {
     formData.data = res;
     console.log(formData);

+ 462 - 0
src/views/product/material/index.vue

@@ -0,0 +1,462 @@
+<template>
+  <div class="user">
+    <div class="tree">
+      <treeList
+        title="物料分类"
+        submitType="2"
+        :data="treeListData"
+        v-model="sourceList.pagination.productClassifyId"
+        @change="treeChange"
+        @changeTreeList="getTreeList"
+      >
+      </treeList>
+    </div>
+    <div class="content">
+      <byTable
+        :source="sourceList.data"
+        :pagination="sourceList.pagination"
+        :config="config"
+        :loading="loading"
+        highlight-current-row
+        :selectConfig="selectConfig"
+        :table-events="{
+          //element talbe事件都能传
+          select: select,
+        }"
+        :action-list="[
+          {
+            text: 'Excel导入',
+            action: () => openExcel(),
+            disabled: false,
+          },
+          {
+            text: '添加物料',
+            action: () => openModal('add'),
+            disabled: false,
+          },
+        ]"
+        @get-list="getList"
+      >
+        <template #slotName="{ item }">
+          {{ item.createTime }}
+        </template>
+      </byTable>
+    </div>
+    <el-dialog
+      :title="modalType == 'add' ? '添加' : '编辑'"
+      v-model="dialogVisible"
+      width="500"
+      v-loading="loading"
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="byform"
+      >
+      </byForm>
+      <template #footer>
+        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
+        <el-button
+          type="primary"
+          @click="submitForm('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+    <el-dialog
+      title="Excel导入"
+      v-model="openExcelDialog"
+      width="400"
+      v-loading="loading"
+    >
+      <template #footer>
+        <el-button @click="openExcelDialog = false" size="large"
+          >取 消</el-button
+        >
+        <el-button
+          type="primary"
+          @click="submitExcel()"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+  
+<script setup>
+/* eslint-disable vue/no-unused-components */
+import { ElMessage, ElMessageBox } from "element-plus";
+import byTable from "@/components/byTable/index";
+import byForm from "@/components/byForm/index";
+import treeList from "../treeList";
+import { computed, defineComponent, ref } from "vue";
+const loading = ref(false);
+const submitLoading = ref(false);
+const sourceList = ref({
+  data: [],
+  pagination: {
+    total: 3,
+    pageNum: 1,
+    pageSize: 10,
+    type: "",
+    productClassifyId: "",
+    keyword: "",
+    definition: "2",
+  },
+});
+let dialogVisible = ref(false);
+let openExcelDialog = ref(false);
+
+let modalType = ref("add");
+let rules = ref({
+  productClassifyId: [
+    { required: true, message: "请选择物料分类", trigger: "change" },
+  ],
+  type: [{ required: true, message: "请选择物料类型", trigger: "change" }],
+  name: [{ required: true, message: "请输入物料名称", trigger: "blur" }],
+  unit: [{ required: true, message: "请选择单位", trigger: "change" }],
+});
+const { proxy } = getCurrentInstance();
+const selectConfig = computed(() => {
+  return [
+    {
+      label: "物料类型",
+      prop: "type",
+      data: [
+        {
+          label: "原料",
+          value: "1",
+        },
+        {
+          label: "辅料",
+          value: "2",
+        },
+        {
+          label: "配件",
+          value: "3",
+        },
+        {
+          label: "包材",
+          value: "4",
+        },
+        {
+          label: "其他",
+          value: "5",
+        },
+      ],
+    },
+  ];
+});
+const config = computed(() => {
+  return [
+    {
+      attrs: {
+        label: "物料类型",
+        prop: "type",
+      },
+      render(type) {
+        return formConfig.value[1].data.find((x) => x.id == type).label;
+      },
+    },
+    {
+      attrs: {
+        label: "物料编码",
+        prop: "code",
+      },
+    },
+    {
+      attrs: {
+        label: "物料名称",
+        prop: "name",
+      },
+    },
+    {
+      attrs: {
+        label: "图片",
+        prop: "unit",
+      },
+    },
+    {
+      attrs: {
+        label: "单位",
+        prop: "unit",
+      },
+    },
+    {
+      attrs: {
+        label: "规格型号",
+        prop: "spec",
+      },
+    },
+    {
+      attrs: {
+        label: "物料备注",
+        prop: "remark",
+      },
+    },
+
+    {
+      attrs: {
+        label: "操作",
+        width: "200",
+        align: "right",
+      },
+      // 渲染 el-button,一般用在最后一列。
+      renderHTML(row) {
+        return [
+          {
+            attrs: {
+              label: "修改",
+              type: "primary",
+              text: true,
+            },
+            el: "button",
+            click() {
+              getDtl(row);
+            },
+          },
+          {
+            attrs: {
+              label: "删除",
+              type: "danger",
+              text: true,
+            },
+            el: "button",
+            click() {
+              // 弹窗提示是否删除
+              ElMessageBox.confirm(
+                "此操作将永久删除该数据, 是否继续?",
+                "提示",
+                {
+                  confirmButtonText: "确定",
+                  cancelButtonText: "取消",
+                  type: "warning",
+                }
+              ).then(() => {
+                // 删除
+                proxy
+                  .post("/productInfo/delete", {
+                    id: row.id,
+                  })
+                  .then((res) => {
+                    ElMessage({
+                      message: "删除成功",
+                      type: "success",
+                    });
+                    getList();
+                  });
+              });
+            },
+          },
+        ];
+      },
+    },
+  ];
+});
+
+let formData = reactive({
+  data: {},
+});
+const formOption = reactive({
+  inline: true,
+  labelWidth: 100,
+  itemWidth: 100,
+  rules: [],
+});
+const byform = ref(null);
+const treeListData = ref([]);
+const formConfig = computed(() => {
+  return [
+    {
+      type: "treeSelect",
+      prop: "productClassifyId",
+      label: "物料分类",
+      data: [],
+    },
+    {
+      type: "select",
+      prop: "type",
+      label: "物料类型",
+      required: true,
+      data: [
+        {
+          label: "原料",
+          id: "1",
+        },
+        {
+          label: "辅料",
+          id: "2",
+        },
+        {
+          label: "配件",
+          id: "3",
+        },
+        {
+          label: "包材",
+          id: "4",
+        },
+        {
+          label: "其他",
+          id: "5",
+        },
+      ],
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "物料名称",
+    },
+    {
+      type: "input",
+      prop: "spec",
+      label: "规格型号",
+    },
+    {
+      type: "select",
+      prop: "unit",
+      label: "单位",
+      required: true,
+      data: [
+        {
+          label: "个",
+          id: "个",
+        },
+        {
+          label: "双",
+          id: "双",
+        },
+      ],
+    },
+
+    {
+      type: "input",
+      prop: "remark",
+      label: "备注",
+      itemType: "textarea",
+    },
+  ];
+});
+const newPassword = () => {
+  formData.data.password = generatePassword();
+};
+const generatePassword = () => {
+  var length = 12,
+    charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+    password = "";
+  for (var i = 0, n = charset.length; i < length; ++i) {
+    password += charset.charAt(Math.floor(Math.random() * n));
+  }
+  return password;
+};
+
+const getList = async (req) => {
+  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  loading.value = true;
+  proxy
+    .post("/productInfo/page", sourceList.value.pagination)
+    .then((message) => {
+      console.log(message);
+      sourceList.value.data = message.rows;
+      sourceList.value.pagination.total = message.total;
+      setTimeout(() => {
+        loading.value = false;
+      }, 200);
+    });
+};
+
+const treeChange = (e) => {
+  console.log(e);
+  sourceList.value.pagination.productClassifyId = e.id;
+  getList({ productClassifyId: e.id });
+};
+
+const openModal = () => {
+  dialogVisible.value = true;
+  modalType.value = "add";
+  formData.data = {
+    definition: "2",
+    fileList: [],
+  };
+};
+
+const openExcel = () => {
+  openExcelDialog.value = true;
+};
+const submitExcel = () => {
+  openExcelDialog.value = false;
+};
+const TreetenantId = ref("");
+const selection = ref({
+  data: [],
+});
+const select = (_selection, row) => {
+  selection.value.data = _selection;
+  console.log(_selection.length);
+};
+
+const tree = ref(null);
+const submitForm = () => {
+  console.log(byform.value);
+  byform.value.handleSubmit((valid) => {
+    submitLoading.value = true;
+    proxy.post("/productInfo/" + modalType.value, formData.data).then(
+      (res) => {
+        ElMessage({
+          message: modalType.value == "add" ? "添加成功" : "编辑成功",
+          type: "success",
+        });
+        dialogVisible.value = false;
+        submitLoading.value = false;
+        getList();
+      },
+      (err) => {
+        submitLoading.value = false;
+      }
+    );
+  });
+};
+
+const getTreeList = () => {
+  proxy
+    .post("/productClassify/tree", { parentId: "", name: "", definition: "2" })
+    .then((message) => {
+      treeListData.value = message;
+      formConfig.value[0].data = message;
+    });
+};
+
+const getDtl = (row) => {
+  modalType.value = "edit";
+  proxy.post("/productInfo/detail", { id: row.id }).then((res) => {
+    res.type = res.type + "";
+    res.definition = "2";
+    res.fileList = [];
+    formData.data = res;
+    dialogVisible.value = true;
+  });
+};
+getTreeList();
+getList();
+</script>
+  
+<style lang="scss" scoped>
+.user {
+  padding: 20px;
+  display: flex;
+  justify-content: space-between;
+  .tree {
+    width: 300px;
+  }
+  .content {
+    width: calc(100% - 320px);
+  }
+}
+</style>

+ 439 - 0
src/views/product/product/index.vue

@@ -0,0 +1,439 @@
+<template>
+  <div class="user">
+    <div class="tree">
+      <treeList
+        title="产品分类"
+        submitType="1"
+        :data="treeListData"
+        v-model="sourceList.pagination.productClassifyId"
+        @change="treeChange"
+        @changeTreeList="getTreeList"
+      >
+      </treeList>
+    </div>
+    <div class="content">
+      <byTable
+        :source="sourceList.data"
+        :pagination="sourceList.pagination"
+        :config="config"
+        :loading="loading"
+        highlight-current-row
+        :selectConfig="selectConfig"
+        :table-events="{
+          //element talbe事件都能传
+          select: select,
+        }"
+        :action-list="[
+          {
+            text: 'Excel导入',
+            action: () => openExcel(),
+            disabled: false,
+          },
+          {
+            text: '添加产品',
+            action: () => openModal('add'),
+            disabled: false,
+          },
+        ]"
+        @get-list="getList"
+      >
+        <template #slotName="{ item }">
+          {{ item.createTime }}
+        </template>
+      </byTable>
+    </div>
+    <el-dialog
+      :title="modalType == 'add' ? '添加' : '编辑'"
+      v-model="dialogVisible"
+      width="500"
+      v-loading="loading"
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="byform"
+      >
+      </byForm>
+      <template #footer>
+        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
+        <el-button
+          type="primary"
+          @click="submitForm('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+    <el-dialog
+      title="Excel导入"
+      v-model="openExcelDialog"
+      width="400"
+      v-loading="loading"
+    >
+      <template #footer>
+        <el-button @click="openExcelDialog = false" size="large"
+          >取 消</el-button
+        >
+        <el-button
+          type="primary"
+          @click="submitExcel()"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+  
+<script setup>
+/* eslint-disable vue/no-unused-components */
+import { ElMessage, ElMessageBox } from "element-plus";
+import byTable from "@/components/byTable/index";
+import byForm from "@/components/byForm/index";
+import treeList from "../treeList";
+import { computed, defineComponent, ref } from "vue";
+const loading = ref(false);
+const submitLoading = ref(false);
+const sourceList = ref({
+  data: [],
+  pagination: {
+    total: 3,
+    pageNum: 1,
+    pageSize: 10,
+    type: "",
+    productClassifyId: "",
+    keyword: "",
+    definition: "1",
+  },
+});
+let dialogVisible = ref(false);
+let openExcelDialog = ref(false);
+
+let modalType = ref("add");
+let rules = ref({
+  productClassifyId: [
+    { required: true, message: "请选择产品分类", trigger: "change" },
+  ],
+  type: [{ required: true, message: "请选择产品类型", trigger: "change" }],
+  name: [{ required: true, message: "请输入产品名称", trigger: "blur" }],
+  unit: [{ required: true, message: "请选择单位", trigger: "change" }],
+});
+const { proxy } = getCurrentInstance();
+const selectConfig = computed(() => {
+  return [
+    {
+      label: "产品类型",
+      prop: "type",
+      data: [
+        {
+          label: "成品",
+          value: "1",
+        },
+        {
+          label: "半成品",
+          value: "2",
+        },
+      ],
+    },
+  ];
+});
+const config = computed(() => {
+  return [
+    {
+      attrs: {
+        label: "产品类型",
+        prop: "type",
+      },
+      render(type) {
+        return type == 1 ? "成品" : type == 2 ? "半成品" : "";
+      },
+    },
+    {
+      attrs: {
+        label: "产品编码",
+        prop: "code",
+      },
+    },
+    {
+      attrs: {
+        label: "产品名称",
+        prop: "name",
+      },
+    },
+    {
+      attrs: {
+        label: "图片",
+        prop: "unit",
+      },
+    },
+    {
+      attrs: {
+        label: "单位",
+        prop: "unit",
+      },
+    },
+    {
+      attrs: {
+        label: "规格型号",
+        prop: "spec",
+      },
+    },
+    {
+      attrs: {
+        label: "产品备注",
+        prop: "remark",
+      },
+    },
+
+    {
+      attrs: {
+        label: "操作",
+        width: "200",
+        align: "right",
+      },
+      // 渲染 el-button,一般用在最后一列。
+      renderHTML(row) {
+        return [
+          {
+            attrs: {
+              label: "修改",
+              type: "primary",
+              text: true,
+            },
+            el: "button",
+            click() {
+              getDtl(row);
+            },
+          },
+          {
+            attrs: {
+              label: "删除",
+              type: "danger",
+              text: true,
+            },
+            el: "button",
+            click() {
+              // 弹窗提示是否删除
+              ElMessageBox.confirm(
+                "此操作将永久删除该数据, 是否继续?",
+                "提示",
+                {
+                  confirmButtonText: "确定",
+                  cancelButtonText: "取消",
+                  type: "warning",
+                }
+              ).then(() => {
+                // 删除
+                proxy
+                  .post("/productInfo/delete", {
+                    id: row.id,
+                  })
+                  .then((res) => {
+                    ElMessage({
+                      message: "删除成功",
+                      type: "success",
+                    });
+                    getList();
+                  });
+              });
+            },
+          },
+        ];
+      },
+    },
+  ];
+});
+
+let formData = reactive({
+  data: {},
+});
+const formOption = reactive({
+  inline: true,
+  labelWidth: 100,
+  itemWidth: 100,
+  rules: [],
+});
+const byform = ref(null);
+const treeListData = ref([]);
+const formConfig = computed(() => {
+  return [
+    {
+      type: "treeSelect",
+      prop: "productClassifyId",
+      label: "产品分类",
+      data: [],
+    },
+    {
+      type: "select",
+      prop: "type",
+      label: "产品类型",
+      required: true,
+      data: [
+        {
+          label: "成品",
+          id: "1",
+        },
+        {
+          label: "半成品",
+          id: "2",
+        },
+      ],
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "产品名称",
+    },
+    {
+      type: "input",
+      prop: "spec",
+      label: "规格型号",
+    },
+    {
+      type: "select",
+      prop: "unit",
+      label: "单位",
+      required: true,
+      data: [
+        {
+          label: "个",
+          id: "个",
+        },
+        {
+          label: "双",
+          id: "双",
+        },
+      ],
+    },
+
+    {
+      type: "input",
+      prop: "remark",
+      label: "备注",
+      itemType: "textarea",
+    },
+  ];
+});
+const newPassword = () => {
+  formData.data.password = generatePassword();
+};
+const generatePassword = () => {
+  var length = 12,
+    charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+    password = "";
+  for (var i = 0, n = charset.length; i < length; ++i) {
+    password += charset.charAt(Math.floor(Math.random() * n));
+  }
+  return password;
+};
+
+const getList = async (req) => {
+  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  loading.value = true;
+  proxy
+    .post("/productInfo/page", sourceList.value.pagination)
+    .then((message) => {
+      console.log(message);
+      sourceList.value.data = message.rows;
+      sourceList.value.pagination.total = message.total;
+      setTimeout(() => {
+        loading.value = false;
+      }, 200);
+    });
+};
+
+const treeChange = (e) => {
+  console.log(e);
+  sourceList.value.pagination.productClassifyId = e.id;
+  getList({ productClassifyId: e.id });
+};
+
+const openModal = () => {
+  dialogVisible.value = true;
+  modalType.value = "add";
+  formData.data = {
+    definition: "1",
+    type: "1",
+    fileList: [],
+  };
+};
+
+const openExcel = () => {
+  openExcelDialog.value = true;
+};
+const submitExcel = () => {
+  openExcelDialog.value = false;
+};
+const TreetenantId = ref("");
+const selection = ref({
+  data: [],
+});
+const select = (_selection, row) => {
+  selection.value.data = _selection;
+  console.log(_selection.length);
+};
+
+const tree = ref(null);
+const submitForm = () => {
+  console.log(byform.value);
+  byform.value.handleSubmit((valid) => {
+    submitLoading.value = true;
+    proxy.post("/productInfo/" + modalType.value, formData.data).then(
+      (res) => {
+        ElMessage({
+          message: modalType.value == "add" ? "添加成功" : "编辑成功",
+          type: "success",
+        });
+        dialogVisible.value = false;
+        submitLoading.value = false;
+        getList();
+      },
+      (err) => {
+        submitLoading.value = false;
+      }
+    );
+  });
+};
+
+const getTreeList = () => {
+  proxy
+    .post("/productClassify/tree", { parentId: "", name: "", definition: "1" })
+    .then((message) => {
+      treeListData.value = message;
+      formConfig.value[0].data = message;
+    });
+};
+
+const getDtl = (row) => {
+  modalType.value = "edit";
+  proxy.post("/productInfo/detail", { id: row.id }).then((res) => {
+    res.type = res.type + "";
+    res.definition = "1";
+    res.fileList = [];
+    formData.data = res;
+    dialogVisible.value = true;
+  });
+};
+getTreeList();
+getList();
+</script>
+  
+<style lang="scss" scoped>
+.user {
+  padding: 20px;
+  display: flex;
+  justify-content: space-between;
+  .tree {
+    width: 300px;
+  }
+  .content {
+    width: calc(100% - 320px);
+  }
+}
+</style>

+ 259 - 0
src/views/product/treeList.vue

@@ -0,0 +1,259 @@
+<template>
+  <div class="treeList">
+    <div class="title commons-title">
+      {{ title }}
+    </div>
+    <div class="search">
+      <el-input
+        v-model="search"
+        placeholder="请输入搜索内容"
+        clearable
+        @clear="search = ''"
+        @keyup.enter="searchChange"
+      ></el-input>
+      <!-- <el-button type="primary" @click="searchChange">搜索</el-button> -->
+      <el-button type="primary" plain @click="add({ id: 0 })">
+        <el-icon :size="20">
+          <Plus />
+        </el-icon>
+      </el-button>
+    </div>
+    <el-tree
+      :data="data"
+      ref="tree"
+      node-key="id"
+      @node-click="treeChange"
+      default-expand-all
+      :filter-node-method="filterNode"
+    >
+      <template #default="{ node, data }">
+        <div class="custom-tree-node">
+          <div style="flex: 1">{{ node.label }}</div>
+          <div style="float: right">
+            <el-icon :size="17" @click.stop="() => edit(node, data)">
+              <Edit />
+            </el-icon>
+            <el-icon
+              :size="17"
+              style="margin-left: 10px"
+              @click.stop="() => add(data)"
+            >
+              <Plus />
+            </el-icon>
+            <el-icon
+              :size="17"
+              style="margin-left: 10px"
+              @click.stop="() => del(data)"
+            >
+              <Delete />
+            </el-icon>
+          </div>
+        </div>
+      </template>
+    </el-tree>
+  </div>
+  <el-dialog
+    :title="treeModalType == 'add' ? '添加分类' : '编辑分类'"
+    v-model="treeModal"
+    width="400"
+    v-loading="loading"
+  >
+    <byForm
+      :formConfig="formConfig"
+      :formOption="formOption"
+      v-model="formData.data"
+      :rules="rules"
+      ref="byform"
+    >
+    </byForm>
+    <template #footer>
+      <el-button @click="treeModal = false" size="large">取 消</el-button>
+      <el-button
+        type="primary"
+        @click="submitForm('byform')"
+        size="large"
+        :loading="submitLoading"
+      >
+        确 定
+      </el-button>
+    </template>
+  </el-dialog>
+</template>
+<script setup>
+import { toRaw } from "vue";
+import { ElMessage, ElMessageBox } from "element-plus";
+import byForm from "@/components/byForm/index";
+
+const props = defineProps({
+  title: {
+    type: String,
+    default: "分类",
+  },
+  submitType: {
+    type: String,
+    default: "1", //默认产品
+  },
+  data: {
+    type: Array,
+    default: [],
+  },
+});
+onMounted(() => {});
+const search = ref("");
+const emit = defineEmits(["update:modelValue"]);
+const { proxy } = getCurrentInstance();
+const treeChange = (e, data) => {
+  if (proxy.type == "radio") {
+    emit("update:modelValue", e.id);
+    emit("change", e);
+  } else {
+    emit("change", e);
+  }
+};
+
+const filterNode = (value, data, node) => {
+  if (!value) return true;
+  return data.label.indexOf(value) !== -1;
+};
+
+const searchChange = () => {
+  proxy.$refs.tree.filter(search.value);
+};
+const byform = ref(null);
+const treeListData = ref([]);
+let treeModal = ref(false);
+let submitLoading = ref(false);
+let treeModalType = ref("add");
+let currentNode = reactive({
+  id: "",
+});
+let formData = reactive({
+  data: {
+    name: "",
+    parentId: "",
+    definition: props.submitType,
+  },
+});
+const formOption = reactive({
+  inline: true,
+  labelWidth: 100,
+  itemWidth: 100,
+  rules: [],
+});
+let rules = ref({
+  name: [{ required: true, message: "请输入分类名称", trigger: "blur" }],
+});
+const formConfig = computed(() => {
+  return [
+    {
+      type: "input",
+      prop: "name",
+      label: "分类名称",
+      required: true,
+    },
+  ];
+});
+const add = (data) => {
+  treeModal.value = true;
+  treeModalType.value = "add";
+  formData.data = {
+    name: "",
+    parentId: "",
+    definition: props.submitType,
+  };
+  formData.data.parentId = data.id;
+};
+
+const edit = (node, data) => {
+  treeModal.value = true;
+  treeModalType.value = "edit";
+  formData.data = {
+    name: data.label,
+    id: data.id,
+    definition: props.submitType,
+  };
+};
+
+const del = (data) => {
+  ElMessageBox.confirm("此操作将永久删除该数据, 是否继续?", "提示", {
+    confirmButtonText: "确定",
+    cancelButtonText: "取消",
+    type: "warning",
+  }).then(() => {
+    // 删除
+    proxy
+      .post("/productClassify/delete", {
+        id: data.id,
+      })
+      .then((res) => {
+        ElMessage({
+          message: "删除成功",
+          type: "success",
+        });
+        getTreeList();
+      });
+  });
+};
+const submitForm = () => {
+  byform.value.handleSubmit((valid) => {
+    submitLoading.value = true;
+    proxy.post("/productClassify/" + treeModalType.value, formData.data).then(
+      (res) => {
+        ElMessage({
+          message: treeModalType.value == "add" ? "添加成功" : "编辑成功",
+          type: "success",
+        });
+        getTreeList();
+        treeModal.value = false;
+        submitLoading.value = false;
+      },
+      (err) => {
+        submitLoading.value = false;
+      }
+    );
+  });
+};
+
+const getTreeList = () => {
+  emit("changeTreeList");
+  // proxy
+  //   .post("/productClassify/tree", {
+  //     parentId: "",
+  //     name: "",
+  //     definition: props.submitType,
+  //   })
+  //   .then((message) => {
+  //     treeListData.value = message;
+  //   });
+};
+// getTreeList();
+const handleMouseOver = (data) => {
+  console.log(data, "sss");
+  // currentNode.id = toRaw(data).id;
+};
+</script>
+
+<style lang="scss">
+.custom-tree-node {
+  flex: 1;
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  font-size: 14px;
+  padding-right: 8px;
+}
+.treeList {
+  display: block;
+  height: 100%;
+  background: #fff;
+  padding: 20px;
+  .search {
+    margin-bottom: 20px;
+    .el-input {
+      width: calc(100% - 70px);
+      margin-right: 10px;
+      text-align: center;
+    }
+  }
+}
+</style>

+ 59 - 26
src/views/production/factory/farm/index.vue

@@ -74,8 +74,11 @@ const sourceList = ref({
 let dialogVisible = ref(false);
 let modalType = ref("add");
 let rules = ref({
-  name: [{ required: true, message: "请选择车间类型", trigger: "change" }],
-  endPoint: [{ required: true, message: "请输入车间名称", trigger: "blur" }],
+  type: [{ required: true, message: "请选择车间类型", trigger: "change" }],
+  name: [{ required: true, message: "请输入车间名称", trigger: "blur" }],
+  personLiableId: [
+    { required: true, message: "请选择负责人", trigger: "change" },
+  ],
 });
 const { proxy } = getCurrentInstance();
 const selectConfig = reactive([
@@ -84,15 +87,15 @@ const selectConfig = reactive([
     prop: "type",
     data: [
       {
-        label: "审核中",
+        label: "普通车间",
         value: "1",
       },
       {
-        label: "审核通过",
+        label: "半自动化车间",
         value: "2",
       },
       {
-        label: "审核不通过",
+        label: "自动化车间",
         value: "3",
       },
     ],
@@ -105,9 +108,15 @@ const config = computed(() => {
         label: "车间类型",
         prop: "type",
         width: 120,
-        render(type) {
-          return "华为";
-        },
+      },
+      render(type) {
+        return type == 1
+          ? "普通车间"
+          : type == 2
+          ? "半自动化车间"
+          : type == "3"
+          ? "自动化车间"
+          : "";
       },
     },
     {
@@ -120,7 +129,7 @@ const config = computed(() => {
     {
       attrs: {
         label: "负责人",
-        prop: "personLiableId",
+        prop: "personLiableName",
         width: 100,
       },
     },
@@ -206,36 +215,56 @@ const formConfig = computed(() => {
   return [
     {
       type: "select",
-      prop: "name",
+      prop: "type",
       label: "车间类型",
       required: true,
-      isLoad: {
-        url: "/tdaApplication/page",
-        req: {
-          pageNum: 1,
-          pageSize: 9999,
+      data: [
+        {
+          label: "普通车间",
+          value: "1",
         },
-        labelKey: "appName",
-        labelVal: "id",
-        method: "post",
-        resUrl: "rows",
-      },
+        {
+          label: "半自动化车间",
+          value: "2",
+        },
+        {
+          label: "自动化车间",
+          value: "3",
+        },
+      ],
+      // isLoad: {
+      //   url: "/tdaApplication/page",
+      //   req: {
+      //     pageNum: 1,
+      //     pageSize: 9999,
+      //   },
+      //   labelKey: "appName",
+      //   labelVal: "id",
+      //   method: "post",
+      //   resUrl: "rows",
+      // },
     },
     {
       type: "input",
-      prop: "aa",
+      prop: "name",
       label: "车间名称",
       required: true,
     },
     {
       type: "select",
-      prop: "name",
+      prop: "personLiableId",
       label: "负责人",
-      data: [],
+      isLoad: {
+        url: "/system/user/list?pageNum=1&pageSize=10000",
+        labelKey: "userName",
+        labelVal: "userId",
+        method: "get",
+        resUrl: "rows",
+      },
     },
     {
       type: "input",
-      prop: "secretAccessKey",
+      prop: "remarks",
       label: "车间说明",
       itemType: "textarea",
     },
@@ -273,14 +302,18 @@ const submitForm = () => {
         submitLoading.value = false;
         getList();
       },
-      (err) => (submitLoading.value = false)
+      (err) => {
+        console.log(err, "aswwwww");
+        submitLoading.value = false;
+      }
     );
   });
 };
 
 const getDtl = (row) => {
-  modalType = "edit";
+  modalType.value = "edit";
   proxy.post("/workshop/detail", { id: row.id }).then((res) => {
+    res.type = res.type + "";
     formData.data = res;
     console.log(formData);
     dialogVisible.value = true;

+ 94 - 30
src/views/production/factory/line/index.vue

@@ -75,35 +75,45 @@ let dialogVisible = ref(false);
 let roomDialogVisible = ref(false);
 let modalType = ref("add");
 let rules = ref({
-  name: [{ required: true, message: "请选择车间名称", trigger: "change" }],
-  name: [{ required: true, message: "请选择产线类型", trigger: "change" }],
-  endPoint: [{ required: true, message: "请输入产线名称", trigger: "blur" }],
+  workshopId: [
+    { required: true, message: "请选择车间名称", trigger: "change" },
+  ],
+  type: [{ required: true, message: "请选择产线类型", trigger: "change" }],
+  name: [{ required: true, message: "请输入产线名称", trigger: "blur" }],
 });
 const { proxy } = getCurrentInstance();
-const selectConfig = computed(() => {
-  return [
-    {
-      label: "车间",
-      prop: "workshopId",
-      data: [],
-    },
-    {
-      label: "产线类型",
-      prop: "type",
-      data: [],
-    },
-  ];
-});
+const selectConfig = reactive([
+  {
+    label: "车间",
+    prop: "workshopId",
+    data: [],
+  },
+  {
+    label: "产线类型",
+    prop: "type",
+    data: [
+      {
+        label: "普通产线",
+        value: "1",
+      },
+      {
+        label: "半自动化产线",
+        value: "2",
+      },
+      {
+        label: "自动化产线",
+        value: "3",
+      },
+    ],
+  },
+]);
 const config = computed(() => {
   return [
     {
       attrs: {
         label: "车间名称",
-        prop: "workshopId",
+        prop: "workshopName",
         width: 120,
-        render(type) {
-          return "华为";
-        },
       },
     },
     {
@@ -112,18 +122,27 @@ const config = computed(() => {
         prop: "type",
         width: 150,
       },
+      render(type) {
+        return type == 1
+          ? "普通产线"
+          : type == 2
+          ? "半自动化产线"
+          : type == "3"
+          ? "自动化产线"
+          : "";
+      },
     },
     {
       attrs: {
         label: "产线名称",
         prop: "name",
-        width: 100,
+        width: 150,
       },
     },
     {
       attrs: {
         label: "负责人",
-        prop: "personLiableId",
+        prop: "personLiableName",
         width: 100,
       },
     },
@@ -194,9 +213,7 @@ const config = computed(() => {
 });
 
 let formData = reactive({
-  data: {
-    type: "",
-  },
+  data: {},
 });
 const formOption = reactive({
   inline: true,
@@ -213,14 +230,37 @@ const formConfig = computed(() => {
       prop: "workshopId",
       label: "车间名称",
       required: true,
-      data: [],
+      isLoad: {
+        url: "/workshop/page",
+        req: {
+          pageNum: 1,
+          pageSize: 9999,
+        },
+        labelKey: "name",
+        labelVal: "id",
+        method: "post",
+        resUrl: "rows",
+      },
     },
     {
       type: "select",
       prop: "type",
       label: "产线类型",
       required: true,
-      data: [],
+      data: [
+        {
+          label: "普通产线",
+          value: "1",
+        },
+        {
+          label: "半自动化产线",
+          value: "2",
+        },
+        {
+          label: "自动化产线",
+          value: "3",
+        },
+      ],
     },
     {
       type: "input",
@@ -232,7 +272,13 @@ const formConfig = computed(() => {
       type: "select",
       prop: "personLiableId",
       label: "负责人",
-      data: [],
+      isLoad: {
+        url: "/system/user/list?pageNum=1&pageSize=10000",
+        labelKey: "userName",
+        labelVal: "userId",
+        method: "get",
+        resUrl: "rows",
+      },
     },
     {
       type: "input",
@@ -260,6 +306,7 @@ const openModal = () => {
   dialogVisible.value = true;
   modalType.value = "add";
   formData.data = {};
+  console.log(formData.data, "awss");
 };
 
 const submitForm = () => {
@@ -282,15 +329,32 @@ const submitForm = () => {
 };
 
 const getDtl = (row) => {
-  modalType = "edit";
+  modalType.value = "edit";
   proxy.post("/assemblyLine/detail", { id: row.id }).then((res) => {
+    res.type = res.type + "";
     formData.data = res;
     console.log(formData);
     dialogVisible.value = true;
   });
 };
 
+const selectData = reactive({
+  farmList: [],
+});
+const getSelect = () => {
+  proxy
+    .post("/workshop/page", { pageNum: 1, pageSize: 9999 })
+    .then((message) => {
+      selectData.farmList = message.rows;
+      selectConfig[0].data = selectData.farmList.map((x) => ({
+        label: x.name,
+        value: x.id,
+      }));
+    });
+};
+
 getList();
+getSelect();
 </script>
   
 <style lang="scss" scoped>

+ 396 - 0
src/views/production/project/bom/index.vue

@@ -0,0 +1,396 @@
+<template>
+  <div class="tenant">
+    <!-- <Banner /> -->
+    <div class="content">
+      <byTable
+        :source="sourceList.data"
+        :pagination="sourceList.pagination"
+        :config="config"
+        :loading="loading"
+        highlight-current-row
+        :selectConfig="selectConfig"
+        :table-events="{
+          //element talbe事件都能传
+          select: select,
+        }"
+        :action-list="[
+          {
+            text: '添加BOM',
+            action: () => openModal('add'),
+          },
+        ]"
+        @get-list="getList"
+      >
+        <template #slotName="{ item }">
+          {{ item.createTime }}
+        </template>
+      </byTable>
+    </div>
+    <el-dialog
+      :title="modalType == 'add' ? '添加BOM' : '编辑BOM'"
+      v-model="dialogVisible"
+      width="800"
+      v-loading="loading"
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="byform"
+      >
+        <template #slot>
+          <div>
+            <el-button type="primary" plain>添加物料/半成品</el-button>
+            <el-button type="primary" plain> Excel导入</el-button>
+            <el-form
+              ref="tableForm"
+              :model="formData.data"
+              :rules="rules"
+              label-width="0px"
+              style="margin-top: 15px"
+            >
+              <el-table :data="formData.data.productList">
+                <el-table-column prop="name" label="物料编码" />
+                <el-table-column prop="state" label="物料名称" />
+                <el-table-column prop="city" label="单位" />
+                <el-table-column prop="num" label="数量" width="150">
+                  <template #default="{ row, $index }">
+                    <el-form-item
+                      :prop="'productList.' + $index + '.num'"
+                      :rules="rules.num"
+                      :inline-message="true"
+                    >
+                      <el-input-number
+                        v-model="row.num"
+                        :precision="2"
+                        :controls="false"
+                        :min="1"
+                      />
+                    </el-form-item>
+                  </template>
+                </el-table-column>
+                <el-table-column prop="zip" label="成本" width="150">
+                  <template #default="{ row, $index }">
+                    <el-form-item
+                      :prop="'productList.' + $index + '.num'"
+                      :rules="rules.num"
+                      :inline-message="true"
+                    >
+                      <el-input-number
+                        v-model="row.aa"
+                        :precision="2"
+                        :controls="false"
+                        :min="1"
+                      />
+                    </el-form-item>
+                  </template>
+                </el-table-column>
+                <el-table-column prop="zip" label="操作" width="100">
+                  <template #default>
+                    <el-button type="primary" link>删除</el-button>
+                  </template>
+                </el-table-column>
+              </el-table>
+            </el-form>
+          </div>
+        </template>
+      </byForm>
+      <template #footer>
+        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
+        <el-button
+          type="primary"
+          @click="submitForm('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+  
+<script setup>
+/* eslint-disable vue/no-unused-components */
+import { ElMessage, ElMessageBox } from "element-plus";
+import byTable from "@/components/byTable/index";
+import byForm from "@/components/byForm/index";
+import { computed, defineComponent, ref } from "vue";
+const loading = ref(false);
+const submitLoading = ref(false);
+const sourceList = ref({
+  data: [],
+  pagination: {
+    total: 3,
+    pageNum: 1,
+    pageSize: 10,
+  },
+});
+let dialogVisible = ref(false);
+let modalType = ref("add");
+let rules = ref({
+  type: [{ required: true, message: "请选择车间类型", trigger: "change" }],
+  name: [{ required: true, message: "请输入车间名称", trigger: "blur" }],
+  num: [{ required: true, message: "请输入数量", trigger: "blur" }],
+  personLiableId: [
+    { required: true, message: "请选择负责人", trigger: "change" },
+  ],
+});
+const { proxy } = getCurrentInstance();
+const selectConfig = reactive([
+  // {
+  //   label: "车间类型",
+  //   prop: "type",
+  //   data: [
+  //     {
+  //       label: "普通车间",
+  //       value: "1",
+  //     },
+  //     {
+  //       label: "半自动化车间",
+  //       value: "2",
+  //     },
+  //     {
+  //       label: "自动化车间",
+  //       value: "3",
+  //     },
+  //   ],
+  // },
+]);
+const config = computed(() => {
+  return [
+    {
+      attrs: {
+        label: "产品类型",
+        prop: "name",
+        width: 150,
+      },
+    },
+    {
+      attrs: {
+        label: "产品编码",
+        prop: "name",
+        width: 150,
+      },
+    },
+    {
+      attrs: {
+        label: "产品名称",
+        prop: "remarks",
+      },
+    },
+    {
+      attrs: {
+        label: "状态",
+        prop: "remarks",
+      },
+    },
+    {
+      attrs: {
+        label: "当前版本",
+        prop: "remarks",
+      },
+    },
+    {
+      attrs: {
+        label: "最近维护人",
+        prop: "remarks",
+      },
+    },
+    {
+      attrs: {
+        label: "最近维护时间",
+        prop: "remarks",
+      },
+    },
+    // {
+    //   attrs: {
+    //     label: "BOM文件",
+    //     prop: "type",
+    //     width: 120,
+    //   },
+    //   render(type) {
+    //     return type == 1
+    //       ? "普通车间"
+    //       : type == 2
+    //       ? "半自动化车间"
+    //       : type == "3"
+    //       ? "自动化车间"
+    //       : "";
+    //   },
+    // },
+
+    {
+      attrs: {
+        label: "操作",
+        width: "200",
+        align: "right",
+      },
+      // 渲染 el-button,一般用在最后一列。
+      renderHTML(row) {
+        return [
+          {
+            attrs: {
+              label: "新建版本",
+              type: "primary",
+              text: true,
+            },
+            el: "button",
+            click() {
+              getDtl(row);
+            },
+          },
+          {
+            attrs: {
+              label: "修改",
+              type: "primary",
+              text: true,
+            },
+            el: "button",
+            click() {
+              getDtl(row);
+            },
+          },
+          {
+            attrs: {
+              label: "禁用",
+              type: "primary",
+              text: true,
+            },
+            el: "button",
+            click() {
+              getDtl(row);
+            },
+          },
+          // {
+          //   attrs: {
+          //     label: "删除",
+          //     type: "danger",
+          //     text: true,
+          //   },
+          //   el: "button",
+          //   click() {
+          //     // 弹窗提示是否删除
+          //     ElMessageBox.confirm(
+          //       "此操作将永久删除该数据, 是否继续?",
+          //       "提示",
+          //       {
+          //         confirmButtonText: "确定",
+          //         cancelButtonText: "取消",
+          //         type: "warning",
+          //       }
+          //     ).then(() => {
+          //       // 删除
+          //       proxy
+          //         .post("/workshop/delete", {
+          //           id: row.id,
+          //         })
+          //         .then((res) => {
+          //           ElMessage({
+          //             message: "删除成功",
+          //             type: "success",
+          //           });
+          //           getList();
+          //         });
+          //     });
+          //   },
+          // },
+        ];
+      },
+    },
+  ];
+});
+
+let formData = reactive({
+  data: {
+    type: "1",
+  },
+});
+const formOption = reactive({
+  inline: true,
+  labelWidth: 100,
+  itemWidth: 100,
+  rules: [],
+});
+const byform = ref(null);
+const formConfig = computed(() => {
+  return [
+    {
+      type: "select",
+      prop: "name",
+      label: "产品名称",
+      required: true,
+    },
+    {
+      type: "slot",
+      slotName: "slot",
+      label: "物料信息",
+    },
+  ];
+});
+const getList = async (req) => {
+  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  loading.value = true;
+  proxy.post("/workshop/page", sourceList.value.pagination).then((message) => {
+    console.log(message);
+    sourceList.value.data = message.rows;
+    sourceList.value.pagination.total = message.total;
+    setTimeout(() => {
+      loading.value = false;
+    }, 200);
+  });
+};
+const openModal = () => {
+  dialogVisible.value = true;
+  modalType.value = "add";
+  formData.data = {};
+  formData.data.productList = [
+    {
+      num: "",
+    },
+  ];
+};
+const submitForm = () => {
+  proxy.$refs.tableForm.validate((vaild) => {
+    if (vaild) {
+      byform.value.handleSubmit((valid) => {
+        submitLoading.value = true;
+        proxy.post("/workshop/" + modalType.value, formData.data).then(
+          (res) => {
+            ElMessage({
+              message: modalType.value == "add" ? "添加成功" : "编辑成功",
+              type: "success",
+            });
+            dialogVisible.value = false;
+            submitLoading.value = false;
+            getList();
+          },
+          (err) => {
+            console.log(err, "aswwwww");
+            submitLoading.value = false;
+          }
+        );
+      });
+    }
+  });
+};
+
+const getDtl = (row) => {
+  modalType.value = "edit";
+  proxy.post("/workshop/detail", { id: row.id }).then((res) => {
+    res.type = res.type + "";
+    formData.data = res;
+    console.log(formData);
+    dialogVisible.value = true;
+  });
+};
+
+// getList();
+</script>
+  
+<style lang="scss" scoped>
+.tenant {
+  padding: 20px;
+}
+</style>

+ 368 - 0
src/views/production/project/processes/index.vue

@@ -0,0 +1,368 @@
+<template>
+  <div class="tenant">
+    <!-- <Banner /> -->
+    <div class="content">
+      <byTable
+        :source="sourceList.data"
+        :pagination="sourceList.pagination"
+        :config="config"
+        :loading="loading"
+        highlight-current-row
+        :selectConfig="selectConfig"
+        :table-events="{
+          //element talbe事件都能传
+          select: select,
+        }"
+        :action-list="[
+          {
+            text: '添加工序',
+            action: () => openModal('add'),
+          },
+        ]"
+        @get-list="getList"
+      >
+        <template #fileSlot="{ item }">
+          <div
+            style="cursor: pointer; color: #409eff"
+            @click="handleClickFile(item)"
+          >
+            {{ item.fileName }}
+          </div>
+        </template>
+      </byTable>
+    </div>
+    <el-dialog
+      :title="modalType == 'add' ? '添加工序' : '编辑工序'"
+      v-model="dialogVisible"
+      width="800"
+      v-loading="loading"
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="byform"
+      >
+        <template #slot>
+          <div>
+            <el-upload
+              v-model:fileList="fileList"
+              class="upload-demo"
+              action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
+              :limit="3"
+              :data="uploadData"
+              :on-preview="handlePreview"
+              :on-remove="handleRemove"
+              :on-success="handleSuccess"
+              :before-upload="handleBeforeUpload"
+              accept="pdf"
+            >
+              <el-button type="primary">点击上传</el-button>
+              <template #file>
+                <div>
+                  <div style="margin-top: 15px">
+                    <el-tag
+                      class="ml-2"
+                      type="info"
+                      v-for="(item, index) in fileList"
+                      :key="index"
+                      closable
+                      @close="handleClose(index)"
+                      >{{ item.fileName }}</el-tag
+                    >
+                  </div>
+                </div>
+              </template>
+            </el-upload>
+          </div>
+        </template>
+      </byForm>
+      <template #footer>
+        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
+        <el-button
+          type="primary"
+          @click="submitForm('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+  
+<script setup>
+/* eslint-disable vue/no-unused-components */
+import { ElMessage, ElMessageBox } from "element-plus";
+import byTable from "@/components/byTable/index";
+import byForm from "@/components/byForm/index";
+import FileUpload from "@/components/FileUpload/index";
+import { computed, defineComponent, ref } from "vue";
+import { getToken } from "@/utils/auth";
+
+const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + "/common/upload"); // 上传文件服务器地址
+const headers = ref({ Authorization: "Bearer " + getToken() });
+const uploadData = ref({});
+const loading = ref(false);
+const submitLoading = ref(false);
+const sourceList = ref({
+  data: [],
+  pagination: {
+    total: 3,
+    pageNum: 1,
+    pageSize: 10,
+  },
+});
+let dialogVisible = ref(false);
+let modalType = ref("add");
+let fileList = ref([]);
+let rules = ref({
+  name: [{ required: true, message: "请输入工序名称", trigger: "blur" }],
+});
+const { proxy } = getCurrentInstance();
+const selectConfig = reactive([
+  // {
+  //   label: "车间类型",
+  //   prop: "type",
+  //   data: [
+  //     {
+  //       label: "普通车间",
+  //       value: "1",
+  //     },
+  //     {
+  //       label: "半自动化车间",
+  //       value: "2",
+  //     },
+  //     {
+  //       label: "自动化车间",
+  //       value: "3",
+  //     },
+  //   ],
+  // },
+]);
+const config = computed(() => {
+  return [
+    {
+      attrs: {
+        label: "工序名称",
+        prop: "name",
+      },
+    },
+    {
+      attrs: {
+        label: "工序说明",
+        prop: "remarks",
+      },
+    },
+    {
+      attrs: {
+        label: "工序文件",
+        prop: "fileName",
+        slot: "fileSlot",
+      },
+      // render(fileName) {
+      //   return <div>fileName</div>;
+      // },
+    },
+
+    {
+      attrs: {
+        label: "操作",
+        width: "200",
+        align: "right",
+      },
+      // 渲染 el-button,一般用在最后一列。
+      renderHTML(row) {
+        return [
+          {
+            attrs: {
+              label: "修改",
+              type: "primary",
+              text: true,
+            },
+            el: "button",
+            click() {
+              getDtl(row);
+            },
+          },
+          {
+            attrs: {
+              label: "删除",
+              type: "danger",
+              text: true,
+            },
+            el: "button",
+            click() {
+              // 弹窗提示是否删除
+              ElMessageBox.confirm(
+                "此操作将永久删除该数据, 是否继续?",
+                "提示",
+                {
+                  confirmButtonText: "确定",
+                  cancelButtonText: "取消",
+                  type: "warning",
+                }
+              ).then(() => {
+                // 删除
+                proxy
+                  .post("/productionProcesses/delete", {
+                    id: row.id,
+                  })
+                  .then((res) => {
+                    ElMessage({
+                      message: "删除成功",
+                      type: "success",
+                    });
+                    getList();
+                  });
+              });
+            },
+          },
+        ];
+      },
+    },
+  ];
+});
+
+let formData = reactive({
+  data: {
+    type: "1",
+  },
+});
+const formOption = reactive({
+  inline: true,
+  labelWidth: 100,
+  itemWidth: 100,
+  rules: [],
+});
+const byform = ref(null);
+const formConfig = computed(() => {
+  return [
+    {
+      type: "input",
+      prop: "name",
+      label: "工序名称",
+      required: true,
+    },
+    {
+      type: "input",
+      prop: "remarks",
+      label: "工序说明",
+      itemType: "textarea",
+    },
+    {
+      type: "slot",
+      slotName: "slot",
+      label: "上传附件",
+    },
+  ];
+});
+const getList = async (req) => {
+  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  loading.value = true;
+  proxy
+    .post("/productionProcesses/page", sourceList.value.pagination)
+    .then((message) => {
+      console.log(message);
+      sourceList.value.data = message.rows;
+      sourceList.value.pagination.total = message.total;
+      setTimeout(() => {
+        loading.value = false;
+      }, 200);
+    });
+};
+const openModal = () => {
+  dialogVisible.value = true;
+  modalType.value = "add";
+  formData.data = {};
+};
+
+const submitForm = () => {
+  if (fileList.value.length > 0) {
+    byform.value.handleSubmit((valid) => {
+      formData.data.fileList = fileList.value;
+      submitLoading.value = true;
+      proxy.post("/productionProcesses/" + modalType.value, formData.data).then(
+        (res) => {
+          ElMessage({
+            message: modalType.value == "add" ? "添加成功" : "编辑成功",
+            type: "success",
+          });
+          fileList.value = [];
+          dialogVisible.value = false;
+          submitLoading.value = false;
+          getList();
+        },
+        (err) => {
+          console.log(err, "aswwwww");
+          submitLoading.value = false;
+        }
+      );
+    });
+  } else {
+    return ElMessage({
+      message: "请上传附件!",
+      type: "info",
+    });
+  }
+};
+
+const getDtl = (row) => {
+  modalType.value = "edit";
+  proxy.post("/productionProcesses/detail", { id: row.id }).then((res) => {
+    fileList.value = [
+      {
+        id: "",
+        fileName: res.fileName,
+        path: "",
+      },
+    ];
+    formData.data = res;
+    dialogVisible.value = true;
+  });
+};
+const handleBeforeUpload = async (file) => {
+  const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
+  uploadData.value = res.uploadBody;
+  fileList.value = [
+    {
+      id: res.id,
+      fileName: res.fileName,
+      path: res.fileUrl,
+    },
+  ];
+};
+const handleClickFile = (row) => {
+  ElMessage({
+    message: "数据请求中,请稍后!",
+    type: "success",
+  });
+  let id = row.id;
+  proxy.post("/fileInfo/getList", { businessIdList: [id] }).then((res) => {
+    const file = res[id];
+    window.open(file.fileUrl, "_blank");
+  });
+};
+
+const handlePreview = (file) => {
+  console.log(file);
+};
+const handleSuccess = (file) => {
+  console.log(file);
+};
+const handleRemove = (file) => {
+  fileList.value = [];
+};
+const handleClose = (index) => {
+  fileList.value.splice(index, 1);
+};
+getList();
+</script>
+  
+<style lang="scss" scoped>
+.tenant {
+  padding: 20px;
+}
+</style>

+ 427 - 0
src/views/production/project/technology/index.vue

@@ -0,0 +1,427 @@
+<template>
+  <div class="tenant">
+    <!-- <Banner /> -->
+    <div class="content">
+      <byTable
+        :source="sourceList.data"
+        :pagination="sourceList.pagination"
+        :config="config"
+        :loading="loading"
+        highlight-current-row
+        :selectConfig="selectConfig"
+        :table-events="{
+          //element talbe事件都能传
+          select: select,
+        }"
+        :action-list="[
+          {
+            text: '添加工艺',
+            action: () => openModal('add'),
+          },
+        ]"
+        @get-list="getList"
+      >
+        <template #slotName="{ item }">
+          {{ item.createTime }}
+        </template>
+      </byTable>
+    </div>
+    <el-dialog
+      :title="modalType == 'add' ? '添加工艺' : '编辑工艺'"
+      v-model="dialogVisible"
+      width="800"
+      v-loading="loading"
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="byform"
+      >
+        <template #lineSlot>
+          <el-transfer
+            v-model="selectLine"
+            filterable
+            filter-placeholder="搜索"
+            :data="lineData"
+            :titles="['可选', '已选']"
+          >
+            <template #default="{ option }">
+              <div
+                draggable="true"
+                @dragstart="dragStar($event, option)"
+                @dragover="dragOver($event, option)"
+                style="cursor: default"
+              >
+                {{ option.label }}
+              </div>
+            </template>
+          </el-transfer>
+        </template>
+        <template #productSlot>
+          <div>
+            <el-button type="primary" @click="openProduct = true">
+              添加产品
+            </el-button>
+            <div style="margin-top: 15px">
+              <el-tag
+                class="ml-2"
+                type="info"
+                closable
+                v-for="(product, index) in productList"
+                :key="product.id"
+                @close="handleRemove(index)"
+                >{{ product.name }}</el-tag
+              >
+            </div>
+          </div>
+        </template>
+        <!-- :filter-method="filterMethod" -->
+      </byForm>
+      <template #footer>
+        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
+        <el-button
+          type="primary"
+          @click="submitForm('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+    <el-dialog
+      v-model="openProduct"
+      title="选择产品"
+      width="70%"
+      :before-close="handleClose"
+    >
+      <SelectProduct @handleSelect="handleSelect"></SelectProduct>
+      <template #footer>
+        <span class="dialog-footer">
+          <el-button @click="openProduct = false">取消</el-button>
+        </span>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+  
+<script setup>
+/* eslint-disable vue/no-unused-components */
+import { ElMessage, ElMessageBox } from "element-plus";
+import byTable from "@/components/byTable/index";
+import byForm from "@/components/byForm/index";
+import SelectProduct from "@/components/iot/SelectProduct";
+
+import { computed, defineComponent, ref, toRaw } from "vue";
+const loading = ref(false);
+const submitLoading = ref(false);
+const sourceList = ref({
+  data: [],
+  pagination: {
+    total: 3,
+    pageNum: 1,
+    pageSize: 10,
+  },
+});
+let lineData = reactive([
+  {
+    key: "1",
+    label: "测试1",
+    disabled: false,
+  },
+  {
+    key: "2",
+    label: "测试2",
+    disabled: false,
+  },
+  {
+    key: "3",
+    label: "测试3",
+    disabled: false,
+  },
+  {
+    key: "4",
+    label: "测试4",
+    disabled: false,
+  },
+]);
+let selectLine = ref([]);
+let dialogVisible = ref(false);
+let openProduct = ref(false);
+let modalType = ref("add");
+let rules = ref({
+  type: [{ required: true, message: "请选择车间类型", trigger: "change" }],
+  name: [{ required: true, message: "请输入车间名称", trigger: "blur" }],
+  personLiableId: [
+    { required: true, message: "请选择负责人", trigger: "change" },
+  ],
+});
+const { proxy } = getCurrentInstance();
+const selectConfig = reactive([
+  // {
+  //   label: "车间类型",
+  //   prop: "type",
+  //   data: [
+  //     {
+  //       label: "普通车间",
+  //       value: "1",
+  //     },
+  //     {
+  //       label: "半自动化车间",
+  //       value: "2",
+  //     },
+  //     {
+  //       label: "自动化车间",
+  //       value: "3",
+  //     },
+  //   ],
+  // },
+]);
+const config = computed(() => {
+  return [
+    {
+      attrs: {
+        label: "工艺名称",
+        prop: "name",
+        width: 150,
+      },
+    },
+    {
+      attrs: {
+        label: "工艺路线",
+        prop: "remarks",
+      },
+    },
+    {
+      attrs: {
+        label: "适用产品",
+        prop: "type",
+        width: 120,
+      },
+      render(type) {
+        return type == 1
+          ? "普通车间"
+          : type == 2
+          ? "半自动化车间"
+          : type == "3"
+          ? "自动化车间"
+          : "";
+      },
+    },
+    {
+      attrs: {
+        label: "工艺说明",
+        prop: "remarks",
+      },
+    },
+    {
+      attrs: {
+        label: "操作",
+        width: "200",
+        align: "right",
+      },
+      // 渲染 el-button,一般用在最后一列。
+      renderHTML(row) {
+        return [
+          {
+            attrs: {
+              label: "修改",
+              type: "primary",
+              text: true,
+            },
+            el: "button",
+            click() {
+              getDtl(row);
+            },
+          },
+          {
+            attrs: {
+              label: "删除",
+              type: "danger",
+              text: true,
+            },
+            el: "button",
+            click() {
+              // 弹窗提示是否删除
+              ElMessageBox.confirm(
+                "此操作将永久删除该数据, 是否继续?",
+                "提示",
+                {
+                  confirmButtonText: "确定",
+                  cancelButtonText: "取消",
+                  type: "warning",
+                }
+              ).then(() => {
+                // 删除
+                proxy
+                  .post("/workshop/delete", {
+                    id: row.id,
+                  })
+                  .then((res) => {
+                    ElMessage({
+                      message: "删除成功",
+                      type: "success",
+                    });
+                    getList();
+                  });
+              });
+            },
+          },
+        ];
+      },
+    },
+  ];
+});
+
+let formData = reactive({
+  data: {
+    type: "1",
+  },
+});
+const formOption = reactive({
+  inline: true,
+  labelWidth: 100,
+  itemWidth: 100,
+  rules: [],
+});
+const byform = ref(null);
+const formConfig = computed(() => {
+  return [
+    {
+      type: "input",
+      prop: "name",
+      label: "工艺名称",
+      required: true,
+    },
+    {
+      type: "slot",
+      slotName: "lineSlot",
+      label: "工艺路线",
+    },
+    {
+      type: "slot",
+      slotName: "productSlot",
+      label: "适用产品",
+    },
+
+    {
+      type: "input",
+      prop: "remarks",
+      label: "车间说明",
+      itemType: "textarea",
+    },
+  ];
+});
+const getList = async (req) => {
+  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  loading.value = true;
+  proxy.post("/workshop/page", sourceList.value.pagination).then((message) => {
+    console.log(message);
+    sourceList.value.data = message.rows;
+    sourceList.value.pagination.total = message.total;
+    setTimeout(() => {
+      loading.value = false;
+    }, 200);
+  });
+};
+const openModal = () => {
+  dialogVisible.value = true;
+  modalType.value = "add";
+  formData.data = {};
+};
+
+const submitForm = () => {
+  console.log(byform.value);
+  byform.value.handleSubmit((valid) => {
+    submitLoading.value = true;
+    proxy.post("/workshop/" + modalType.value, formData.data).then(
+      (res) => {
+        ElMessage({
+          message: modalType.value == "add" ? "添加成功" : "编辑成功",
+          type: "success",
+        });
+        dialogVisible.value = false;
+        submitLoading.value = false;
+        getList();
+      },
+      (err) => {
+        console.log(err, "aswwwww");
+        submitLoading.value = false;
+      }
+    );
+  });
+};
+
+const getDtl = (row) => {
+  modalType.value = "edit";
+  proxy.post("/workshop/detail", { id: row.id }).then((res) => {
+    res.type = res.type + "";
+    formData.data = res;
+    console.log(formData);
+    dialogVisible.value = true;
+  });
+};
+
+const filterMethod = (query, item) => {
+  return item.initial.toLowerCase().includes(query.toLowerCase());
+};
+const productList = ref([]);
+
+const handleSelect = (row) => {
+  const flag = productList.value.some((x) => x.id === row.id);
+  if (flag)
+    return ElMessage({
+      message: "该产品已选择",
+      type: "info",
+    });
+  productList.value.push(row);
+  return ElMessage({
+    message: "选择成功",
+    type: "success",
+  });
+};
+
+const handleRemove = (index) => {
+  productList.value.splice(index, 1);
+  return ElMessage({
+    message: "删除成功",
+    type: "success",
+  });
+};
+
+// const renderDom = (h, option) => {
+//   console.log(option, "ass");
+//    h(lineData.map(x=> {
+//     return `<div>${x.x.label}}</div>`
+//   })
+// };
+// getList();
+let dom = ref(null);
+let selectItem = ref({});
+const dragStar = (e, option) => {
+  dom.value = e.target;
+  const target = e.target;
+  selectItem.value = option;
+  e.dataTransfer.setData("text/plain", target.id);
+  e.dataTransfer.effectAllowed = "move";
+};
+const dragOver = (e, option) => {
+  e.preventDefault();
+  const index = selectLine.value.findIndex(
+    (x) => x.key === selectItem.value.key
+  );
+  const index1 = selectLine.value.findIndex((x) => x.key === toRaw(option).key);
+  const item = selectLine.value[index];
+  selectLine.value[index] = selectLine.value[index1];
+  selectLine.value[index1] = item;
+  console.log(selectLine.value);
+};
+</script>
+  
+<style lang="scss" scoped>
+.tenant {
+  padding: 20px;
+}
+</style>

+ 427 - 421
src/views/system/dept2/index.vue

@@ -1,170 +1,171 @@
 <template>
-	<div class="dept">
-		<div class="tree">
-			<treeList
-				:data="treeListData"
-				v-model="sourceList.pagination.tenantId"
-				node-key="id"
-				@change="treeChange"
-			>
-			</treeList>
-		</div>
-		<div class="content">
-			<byTable
-				:hideTable="true"
-				:hidePagination="true"
-				:config="config"
-				:loading="loading"
-				highlight-current-row
-				:selectConfig="selectConfig"
-				:table-events="{
-					//element talbe事件都能传
-					select: select,
-				}"
-				:action-list="[
-					{
-						text: '添加机构',
-						action: () => openModal('add'),
-						disabled: !sourceList.pagination.tenantId,
-					},
-				]"
-				@get-list="getList"
-			>
-				<template #slotName="{ item }">
-					{{ item.createTime }}
-				</template>
-			</byTable>
-			<el-table
-				v-loading="loading"
-				:data="sourceList.data"
-				row-key="deptId"
-				style="padding: 0 20px; box-sizing: border-box"
-				:tree-props="{
-					children: 'children',
-					hasChildren: 'hasChildren',
-				}"
-			>
-				<el-table-column
-					prop="deptName"
-					label="机构名称"
-					width="260"
-				></el-table-column>
-				<el-table-column
-					prop="orderNum"
-					label="排序"
-					width="100"
-				></el-table-column>
-				<el-table-column prop="type" label="机构类型" width="100">
-				</el-table-column>
-				<el-table-column
-					label="创建时间"
-					align="center"
-					prop="createTime"
-					width="200"
-				>
-					<template #default="scope">
-						<span>{{ parseTime(scope.row.createTime) }}</span>
-					</template>
-				</el-table-column>
-				<el-table-column
-					label="操作"
-					align="center"
-					class-name="small-padding fixed-width"
-				>
-					<template #default="scope">
-						<el-button
-							link
-							type="primary"
-							@click="getDtl(scope.row)"
-							v-hasPermi="['system:dept:edit']"
-							>修改</el-button
-						>
-						<el-button
-							link
-							type="primary"
-							@click="handleAdd(scope.row)"
-							v-hasPermi="['system:dept:add']"
-							>新增</el-button
-						>
-						<el-button
-							v-if="scope.row.parentId != 0"
-							link
-							type="primary"
-							@click="listDelete(scope.row)"
-							v-hasPermi="['system:dept:remove']"
-							>删除</el-button
-						>
-					</template>
-				</el-table-column>
-			</el-table>
-		</div>
-		<el-dialog
-			:title="modalType == 'add' ? '新增' : '编辑'"
-			v-model="dialogVisible"
-			width="500"
-			v-loading="loading"
-		>
-			<byForm
-				:formConfig="formConfig"
-				:formOption="formOption"
-				v-model="formData.data"
-				:rules="rules"
-				ref="byform"
-			>
-				<template #account>
-					<el-input
-						style="width: 150px; margin-right: 10px"
-						v-model="formData.data.userName"
-						placeholder="请输入用户名"
-					></el-input>
-					<el-input
-						style="width: 150px; margin-right: 10px"
-						v-model="formData.data.password"
-						placeholder="密码"
-					></el-input>
-					<span
-						style="color: #409eff; cursor: pointer"
-						@click="newPassword"
-						>随机生成</span
-					>
-				</template>
-			</byForm>
-			<template #footer>
-				<el-button @click="dialogVisible = false" size="large"
-					>取 消</el-button
-				>
-				<el-button
-					type="primary"
-					@click="submitForm('byform')"
-					size="large"
-					:loading="submitLoading"
-				>
-					确 定
-				</el-button>
-			</template>
-		</el-dialog>
-		<el-dialog
-			title="修改密码"
-			v-model="roomDialogVisible"
-			width="500"
-			:before-close="handleClose"
-			v-loading="loading"
-		>
-			<template #footer>
-				<el-button @click="roomDialogVisible = false" size="large"
-					>取 消</el-button
-				>
-				<el-button
-					type="primary"
-					@click="submitTree('byform')"
-					size="large"
-					:loading="submitLoading"
-				>
-					确 定
-				</el-button>
-			</template>
-		</el-dialog>
-	</div>
+  <div class="dept">
+    <div class="tree">
+      <treeList
+        :data="treeListData"
+        v-model="sourceList.pagination.tenantId"
+        node-key="id"
+        @change="treeChange"
+      >
+      </treeList>
+    </div>
+    <div class="content">
+      <byTable
+        :hideTable="true"
+        :hidePagination="true"
+        :config="config"
+        :loading="loading"
+        highlight-current-row
+        :selectConfig="selectConfig"
+        :table-events="{
+          //element talbe事件都能传
+          select: select,
+        }"
+        :action-list="[
+          {
+            text: '添加机构',
+            action: () => openModal('add'),
+            disabled: !sourceList.pagination.tenantId,
+          },
+        ]"
+        @get-list="getList"
+      >
+        <template #slotName="{ item }">
+          {{ item.createTime }}
+        </template>
+      </byTable>
+      <el-table
+        v-loading="loading"
+        :data="sourceList.data"
+        row-key="deptId"
+        style="padding: 0 20px; box-sizing: border-box"
+        :tree-props="{
+          children: 'children',
+          hasChildren: 'hasChildren',
+        }"
+      >
+        <el-table-column
+          prop="deptName"
+          label="机构名称"
+          width="260"
+        ></el-table-column>
+        <el-table-column
+          prop="orderNum"
+          label="排序"
+          width="100"
+        ></el-table-column>
+        <el-table-column
+          prop="type"
+          label="机构类型"
+          width="100"
+          :formatter="(row) => showType(row.type)"
+        >
+        </el-table-column>
+        <el-table-column
+          label="创建时间"
+          align="center"
+          prop="createTime"
+          width="200"
+        >
+          <template #default="scope">
+            <span>{{ parseTime(scope.row.createTime) }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column
+          label="操作"
+          align="center"
+          class-name="small-padding fixed-width"
+        >
+          <template #default="scope">
+            <el-button
+              link
+              type="primary"
+              @click="getDtl(scope.row)"
+              v-hasPermi="['system:dept:edit']"
+              >修改</el-button
+            >
+            <el-button
+              link
+              type="primary"
+              @click="handleAdd(scope.row)"
+              v-hasPermi="['system:dept:add']"
+              >新增</el-button
+            >
+            <el-button
+              v-if="scope.row.parentId != 0"
+              link
+              type="primary"
+              @click="listDelete(scope.row)"
+              v-hasPermi="['system:dept:remove']"
+              >删除</el-button
+            >
+          </template>
+        </el-table-column>
+      </el-table>
+    </div>
+    <el-dialog
+      :title="modalType == 'add' ? '新增' : '编辑'"
+      v-model="dialogVisible"
+      width="500"
+      v-loading="loading"
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="byform"
+      >
+        <template #account>
+          <el-input
+            style="width: 150px; margin-right: 10px"
+            v-model="formData.data.userName"
+            placeholder="请输入用户名"
+          ></el-input>
+          <el-input
+            style="width: 150px; margin-right: 10px"
+            v-model="formData.data.password"
+            placeholder="密码"
+          ></el-input>
+          <span style="color: #409eff; cursor: pointer" @click="newPassword"
+            >随机生成</span
+          >
+        </template>
+      </byForm>
+      <template #footer>
+        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
+        <el-button
+          type="primary"
+          @click="submitForm('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+    <el-dialog
+      title="修改密码"
+      v-model="roomDialogVisible"
+      width="500"
+      :before-close="handleClose"
+      v-loading="loading"
+    >
+      <template #footer>
+        <el-button @click="roomDialogVisible = false" size="large"
+          >取 消</el-button
+        >
+        <el-button
+          type="primary"
+          @click="submitTree('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+  </div>
 </template>
   
 <script setup>
@@ -187,85 +188,85 @@ const sourceList = ref({
 let dialogVisible = ref(false);
 let modalType = ref("add");
 let rules = ref({
-	parentId: [{ required: true, message: '请选择上级机构', trigger: 'blur' }],
-	orderNum: [{ required: true, message: '排序不能为空', trigger: 'blur' }],
-	deptName: [{ required: true, message: '机构名称不能为空', trigger: 'blur' }],
-})
-const { proxy } = getCurrentInstance()
+  parentId: [{ required: true, message: "请选择上级机构", trigger: "blur" }],
+  orderNum: [{ required: true, message: "排序不能为空", trigger: "blur" }],
+  deptName: [{ required: true, message: "机构名称不能为空", trigger: "blur" }],
+});
+const { proxy } = getCurrentInstance();
 const selectConfig = computed(() => {
   return [];
 });
 const config = computed(() => {
-	return [
-		{
-			attrs: {
-				label: '机构名称',
-				prop: 'deptName',
-			},
-		},
-		{
-			attrs: {
-				label: '机构类型',
-				prop: 'userName',
-				align: 'left',
-			},
+  return [
+    {
+      attrs: {
+        label: "机构名称",
+        prop: "deptName",
+      },
+    },
+    {
+      attrs: {
+        label: "机构类型",
+        prop: "type",
+        align: "left",
+      },
 
-			render(type) {
-				return type == '0'
-					? '公司'
-					: type == '1'
-					? '业务中心'
-					: type == '2'
-					? '部门'
-					: '组'
-			},
-		},
-		{
-			attrs: {
-				label: '排序',
-				prop: 'nickName',
-			},
-		},
-		{
-			attrs: {
-				label: '创建时间',
-				prop: 'createTime',
-			},
-		},
-		{
-			attrs: {
-				label: '操作',
-				width: '200',
-				align: 'right',
-			},
-			// 渲染 el-button,一般用在最后一列。
-			renderHTML(row) {
-				return [
-					{
-						attrs: {
-							label: '修改',
-							type: 'primary',
-							text: true,
-						},
-						el: 'button',
-						click() {
-							getDtl(row)
-						},
-					},
-					{
-						attrs: {
-							label: '删除',
-							type: 'danger',
-							text: true,
-						},
-						el: 'button',
-						click() {},
-					},
-				]
-			},
-		},
-	]
-})
+      render(type) {
+        return type == "0"
+          ? "公司"
+          : type == "1"
+          ? "业务中心"
+          : type == "2"
+          ? "部门"
+          : "组";
+      },
+    },
+    {
+      attrs: {
+        label: "排序",
+        prop: "nickName",
+      },
+    },
+    {
+      attrs: {
+        label: "创建时间",
+        prop: "createTime",
+      },
+    },
+    {
+      attrs: {
+        label: "操作",
+        width: "200",
+        align: "right",
+      },
+      // 渲染 el-button,一般用在最后一列。
+      renderHTML(row) {
+        return [
+          {
+            attrs: {
+              label: "修改",
+              type: "primary",
+              text: true,
+            },
+            el: "button",
+            click() {
+              getDtl(row);
+            },
+          },
+          {
+            attrs: {
+              label: "删除",
+              type: "danger",
+              text: true,
+            },
+            el: "button",
+            click() {},
+          },
+        ];
+      },
+    },
+  ];
+});
 
 let formData = reactive({
   data: {},
@@ -279,127 +280,126 @@ const formOption = reactive({
 const byform = ref(null);
 const treeListData = ref([]);
 const formConfig = computed(() => {
-	return [
-		{
-			type: 'treeSelect',
-			prop: 'parentId',
-			label: '上级机构',
-			data: [],
-		},
-		{
-			type: 'input',
-			prop: 'deptName',
-			label: '机构名称',
-			required: true,
-			itemWidth: 50,
-			//disabled:true,
-			itemType: 'text',
-		},
+  return [
+    {
+      type: "treeSelect",
+      prop: "parentId",
+      label: "上级机构",
+      data: [],
+    },
+    {
+      type: "input",
+      prop: "deptName",
+      label: "机构名称",
+      required: true,
+      itemWidth: 50,
+      //disabled:true,
+      itemType: "text",
+    },
 
-		{
-			type: 'select',
-			prop: 'type',
-			label: '机构类型',
-			required: true,
+    {
+      type: "select",
+      prop: "type",
+      label: "机构类型",
+      required: true,
 
-			data: [
-				{
-					label: '公司',
-					id: 0,
-				},
-				{
-					label: '业务中心',
-					id: 1,
-				},
-				{
-					label: '部门',
-					id: 2,
-				},
-				{
-					label: '组',
-					id: 3,
-				},
-			],
-		},
-		{
-			type: 'select',
-			label: '负责人',
-			prop: 'leaderId',
-			itemWidth: 50,
-			isLoad: {
-				url: '/tenantUser/list?pageNum=1&pageSize=10000',
-				labelKey: 'userName',
-				labelVal: 'userId',
-				method: 'get',
-				resUrl: 'rows',
-			},
-		},
-		{
-			type: 'select',
-			label: '总监',
-			prop: 'directorId',
-			itemWidth: 50,
-			isLoad: {
-				url: '/tenantUser/list?pageNum=1&pageSize=10000',
-				labelKey: 'userName',
-				labelVal: 'userId',
-				method: 'get',
-				resUrl: 'rows',
-			},
-		},
-		{
-			type: 'input',
-			prop: 'orderNum',
-			label: '排序',
-			required: true,
-			itemWidth: 50,
-			//disabled:true,
-			itemType: 'number',
-		},
-	]
-})
+      data: [
+        {
+          label: "公司",
+          id: 0,
+        },
+        {
+          label: "业务中心",
+          id: 1,
+        },
+        {
+          label: "部门",
+          id: 2,
+        },
+        {
+          label: "组",
+          id: 3,
+        },
+      ],
+    },
+    {
+      type: "select",
+      label: "负责人",
+      prop: "leaderId",
+      itemWidth: 50,
+      isLoad: {
+        url: "/tenantUser/list?pageNum=1&pageSize=10000",
+        labelKey: "userName",
+        labelVal: "userId",
+        method: "get",
+        resUrl: "rows",
+      },
+    },
+    {
+      type: "select",
+      label: "总监",
+      prop: "directorId",
+      itemWidth: 50,
+      isLoad: {
+        url: "/tenantUser/list?pageNum=1&pageSize=10000",
+        labelKey: "userName",
+        labelVal: "userId",
+        method: "get",
+        resUrl: "rows",
+      },
+    },
+    {
+      type: "input",
+      prop: "orderNum",
+      label: "排序",
+      required: true,
+      itemWidth: 50,
+      //disabled:true,
+      itemType: "number",
+    },
+  ];
+});
 const newPassword = () => {
-	formData.data.password = generatePassword()
-}
+  formData.data.password = generatePassword();
+};
 const generatePassword = () => {
-	var length = 12,
-		charset =
-			'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
-		password = ''
-	for (var i = 0, n = charset.length; i < length; ++i) {
-		password += charset.charAt(Math.floor(Math.random() * n))
-	}
-	return password
-}
+  var length = 12,
+    charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+    password = "";
+  for (var i = 0, n = charset.length; i < length; ++i) {
+    password += charset.charAt(Math.floor(Math.random() * n));
+  }
+  return password;
+};
 
 const getTreeList = () => {
-	proxy.post('/tenantInfo/list').then((message) => {
-		message.map((item) => {
-			item.label = item.enterpriseName
-			item.id = item.tenantId
-			item.children = []
-		})
+  proxy.post("/tenantInfo/list").then((message) => {
+    message.map((item) => {
+      item.label = item.enterpriseName;
+      item.id = item.tenantId;
+      item.children = [];
+    });
 
-		treeListData.value = message
-		console.log(treeListData.value)
-	})
-}
+    treeListData.value = message;
+    console.log(treeListData.value);
+  });
+};
 const getList = async (req) => {
-	sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
-	loading.value = true
-	proxy
-		.get('/tenantDept/list', sourceList.value.pagination)
-		.then((message) => {
-			recursive(message.data)
-
-			sourceList.value.data = proxy.handleTree(message.data, 'deptId')
-			console.log(sourceList.value)
-			formConfig.value[0].data = proxy.handleTree(message.data, 'deptId')
-			setTimeout(() => {
-				loading.value = false
-			}, 200)
-		})
-}
+  if (req) {
+    req.deptName = req.keyword;
+  }
+  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  loading.value = true;
+  proxy.get("/tenantDept/list", sourceList.value.pagination).then((message) => {
+    recursive(message.data);
+    sourceList.value.data = proxy.handleTree(message.data, "deptId");
+    console.log(sourceList.value);
+    formConfig.value[0].data = proxy.handleTree(message.data, "deptId");
+    setTimeout(() => {
+      loading.value = false;
+    }, 200);
+  });
+};
 
 const treeChange = (e) => {
   sourceList.value.pagination.tenantId = e.id;
@@ -407,13 +407,13 @@ const treeChange = (e) => {
 };
 
 const handleAdd = (row) => {
-	dialogVisible.value = true;
-	modalType.value = "add";
-	console.log(row)
-	formData.data = {
-		parentId: row.deptId,
-		tenantId: row.tenantId,
-	};
+  dialogVisible.value = true;
+  modalType.value = "add";
+  console.log(row);
+  formData.data = {
+    parentId: row.deptId,
+    tenantId: row.tenantId,
+  };
 };
 
 const openModal = () => {
@@ -433,72 +433,78 @@ const select = (_selection, row) => {
 
 const tree = ref(null);
 const submitForm = () => {
-	byform.value.handleSubmit((valid) => {
-		const method = modalType.value == 'add' ? 'POST' : 'PUT'
-		console.log(method)
-		if(!formData.data.parentId) formData.data.parentId = 0
-		proxy
-			.post(
-				'/tenantDept',
-				{
-					...formData.data,
-					tenantId: formData.data.tenantId ? formData.data.tenantId : sourceList.value.pagination.tenantId,
-				},
-				method
-			)
-			.then((res) => {
-				ElMessage({
-					message: modalType.value == 'add' ? '添加成功' : '编辑成功',
-					type: 'success',
-				})
-				dialogVisible.value = false
-				getList()
-			})
-	})
-}
+  byform.value.handleSubmit((valid) => {
+    const method = modalType.value == "add" ? "POST" : "PUT";
+    console.log(method);
+    if (!formData.data.parentId) formData.data.parentId = 0;
+    proxy
+      .post(
+        "/tenantDept",
+        {
+          ...formData.data,
+          tenantId: formData.data.tenantId
+            ? formData.data.tenantId
+            : sourceList.value.pagination.tenantId,
+        },
+        method
+      )
+      .then((res) => {
+        ElMessage({
+          message: modalType.value == "add" ? "添加成功" : "编辑成功",
+          type: "success",
+        });
+        dialogVisible.value = false;
+        getList();
+      });
+  });
+};
 
 const recursive = (data) => {
-	data.map((item) => {
-		item.label = item.deptName
-		item.id = item.deptId
-		if (item.children) {
-			recursive(item.children)
-		} else {
-			item.children = []
-		}
-	})
-}
+  data.map((item) => {
+    item.label = item.deptName;
+    item.id = item.deptId;
+    if (item.children) {
+      recursive(item.children);
+    } else {
+      item.children = [];
+    }
+  });
+};
 
 const listDelete = (row) => {
-	// 弹窗提示是否删除
-	ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', {
-		confirmButtonText: '确定',
-		cancelButtonText: '取消',
-		type: 'warning',
-	}).then(() => {
-		// 删除
-		proxy
-			.post(
-				'/tenantDept/' + row.deptId,{},'delete'
-			)
-			.then((res) => {
-				ElMessage({
-					message: '删除成功',
-					type: 'success',
-				})
-				getList()
-			})
-	})
-}
-
+  // 弹窗提示是否删除
+  ElMessageBox.confirm("此操作将永久删除该数据, 是否继续?", "提示", {
+    confirmButtonText: "确定",
+    cancelButtonText: "取消",
+    type: "warning",
+  }).then(() => {
+    // 删除
+    proxy.post("/tenantDept/" + row.deptId, {}, "delete").then((res) => {
+      ElMessage({
+        message: "删除成功",
+        type: "success",
+      });
+      getList();
+    });
+  });
+};
+const showType = (type) => {
+  return type == "0"
+    ? "公司"
+    : type == "1"
+    ? "业务中心"
+    : type == "2"
+    ? "部门"
+    : "组";
+};
 const getDtl = (row) => {
-	formData.data = { ...row }
-	modalType.value = 'edit'
-	console.log(modalType.value)
-	dialogVisible.value = true
-}
-getTreeList()
-getList()
+  formData.data = { ...row };
+  modalType.value = "edit";
+  console.log(modalType.value);
+  dialogVisible.value = true;
+};
+getTreeList();
+getList();
 </script>
   
 <style lang="scss" scoped>

+ 427 - 378
src/views/system/tenant/index.vue

@@ -1,408 +1,457 @@
 <template>
-	<div class="tenant">
-		<!-- <Banner /> -->
-		<div class="content">
-			<byTable
-				
-				:source="sourceList.data"
-				:pagination="sourceList.pagination"
-				:config="config"
-				:loading="loading"
-				highlight-current-row
-				:selectConfig="selectConfig"
-				:table-events="{
-					//element talbe事件都能传
-					'select': select,
-				}"
-				:action-list="[
-					{
-						text: '权限配置',
-						plain: true,
-						//type: 'warning',
-						action: () => openRoomModal(),
-						disabled:selection.data.length != 1,
-					},
-					{
-						text: '添加租户',
-						action: () => openModal('add'),
-					},
-				]"
-				@get-list="getList"
-			>
-				<template #slotName="{ item }">
-					{{ item.createTime }}
-				</template>
-			</byTable>
-		</div>
-		<el-dialog
-			:title="modalType == 'add' ? '新增' : '编辑'"
-			v-model="dialogVisible"
-			width="800"
-			v-loading="loading"
-		>
-			<byForm
-				:formConfig="formConfig"
-				:formOption="formOption"
-				v-model="formData.data"
-				:rules="rules"
-				ref="byform"
-			>
-				
-			</byForm>
-			<template #footer>
-				<el-button @click="dialogVisible = false" size="large"
-					>取 消</el-button
-				>
-				<el-button
-					type="primary"
-					@click="submitForm('byform')"
-					size="large"
-					:loading="submitLoading">
-					确 定
-				</el-button>
-			</template>
-		</el-dialog>
-		<el-dialog
-			title="权限配置"
-			v-model="roomDialogVisible"
-			width="500"
-			:before-close="handleClose"
-			v-loading="loading">
-				
-				<el-tree
-					:data="treeData"
-					:show-checkbox="true"
-					v-model="formData.treeData"
-					ref="tree"
-					node-key="id"
-				>
-				</el-tree>
-			<template #footer>
-				<el-button @click="roomDialogVisible = false" size="large"
-					>取 消</el-button
-				>
-				<el-button
-					type="primary"
-					@click="submitTree('byform')"
-					size="large"
-					:loading="submitLoading">
-					确 定
-				</el-button>
-			</template>
-		</el-dialog>
-	</div>
+  <div class="tenant">
+    <!-- <Banner /> -->
+    <div class="content">
+      <byTable
+        :source="sourceList.data"
+        :pagination="sourceList.pagination"
+        :config="config"
+        :loading="loading"
+        highlight-current-row
+        :selectConfig="selectConfig"
+        :table-events="{
+          //element talbe事件都能传
+          select: select,
+        }"
+        :action-list="[
+          {
+            text: '权限配置',
+            plain: true,
+            //type: 'warning',
+            action: () => openRoomModal(),
+            disabled: selection.data.length != 1,
+          },
+          {
+            text: '添加租户',
+            action: () => openModal('add'),
+          },
+        ]"
+        @get-list="getList"
+      >
+        <template #slotName="{ item }">
+          {{ item.createTime }}
+        </template>
+      </byTable>
+    </div>
+    <el-dialog
+      :title="modalType == 'add' ? '新增' : '编辑'"
+      v-model="dialogVisible"
+      width="800"
+      v-loading="loading"
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="byform"
+      >
+      </byForm>
+      <template #footer>
+        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
+        <el-button
+          type="primary"
+          @click="submitForm('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+    <el-dialog
+      title="权限配置"
+      v-model="roomDialogVisible"
+      width="500"
+      :before-close="handleClose"
+      v-loading="loading"
+    >
+      <el-tree
+        :data="treeData"
+        :show-checkbox="true"
+        v-model="formData.treeData"
+        ref="tree"
+        node-key="id"
+      >
+      </el-tree>
+      <template #footer>
+        <el-button @click="roomDialogVisible = false" size="large"
+          >取 消</el-button
+        >
+        <el-button
+          type="primary"
+          @click="submitTree('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+  </div>
 </template>
   
 <script setup>
 /* eslint-disable vue/no-unused-components */
-import { ElMessage, ElMessageBox } from 'element-plus'
-import byTable from '@/components/byTable/index'
-import byForm from '@/components/byForm/index'
-import { computed, defineComponent, ref } from 'vue'
-const loading = ref(false)
-const submitLoading = ref(false)
+import { ElMessage, ElMessageBox } from "element-plus";
+import byTable from "@/components/byTable/index";
+import byForm from "@/components/byForm/index";
+import { computed, defineComponent, ref } from "vue";
+const loading = ref(false);
+const submitLoading = ref(false);
 const sourceList = ref({
-	data: [],
-	pagination: {
-		total: 3,
-		pageNum: 1,
-		pageSize: 10,
-	},
-})
-let dialogVisible = ref(false)
-let roomDialogVisible = ref(false)
-let modalType = ref('add')
+  data: [],
+  pagination: {
+    total: 3,
+    pageNum: 1,
+    pageSize: 10,
+  },
+});
+let dialogVisible = ref(false);
+let roomDialogVisible = ref(false);
+let modalType = ref("add");
 let rules = ref({
-	tenantId: [{ required: true, message: '请输入活动名称', trigger: 'blur' }],
-	password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
-	enterpriseName: [{ required: true, message: '请输入企业名称', trigger: 'blur' }],
-})
-const { proxy } = getCurrentInstance()
+  tenantId: [{ required: true, message: "请输入活动名称", trigger: "blur" }],
+  password: [{ required: true, message: "请输入密码", trigger: "blur" }],
+  enterpriseName: [
+    { required: true, message: "请输入企业名称", trigger: "blur" },
+  ],
+});
+const { proxy } = getCurrentInstance();
 const selectConfig = computed(() => {
-	return [
-		{
-			label: '审核状态',
-			prop: 'flowStatus',
-			data: [
-				{
-					label: '审核中',
-					value: '1',
-				},
-				{
-					label: '审核通过',
-					value: '2',
-				},
-				{
-					label: '审核不通过',
-					value: '3',
-				},
-			],
-		},
-		{
-			label: '启用状态',
-			prop: 'status',
-			data: [
-				{
-					label: '启用',
-					value: '1',
-				},
-				{
-					label: '禁用',
-					value: '0',
-				},
-			],
-		},
-	]
-})
+  return [
+    {
+      label: "审核状态",
+      prop: "flowStatus",
+      data: [
+        {
+          label: "审核中",
+          value: "1",
+        },
+        {
+          label: "审核通过",
+          value: "2",
+        },
+        {
+          label: "审核不通过",
+          value: "3",
+        },
+      ],
+    },
+    {
+      label: "启用状态",
+      prop: "status",
+      data: [
+        {
+          label: "启用",
+          value: "1",
+        },
+        {
+          label: "禁用",
+          value: "0",
+        },
+      ],
+    },
+  ];
+});
 const config = computed(() => {
-	return [
-		{
-			type: 'selection',
-			attrs: {
-				label: '多选',
-				prop: 'remark',
-			},
-		},
-		{
-			attrs: {
-				label: '企业名称',
-				prop: 'enterpriseName',
-			},
-		},
-		{
-			attrs: {
-				label: '租户id',
-				prop: 'tenantId',
-				align: 'center',
-			},
-		},
-		{
-			attrs: {
-				label: '已创建账号数',
-				prop: 'accountCount',
-				align: 'center',
-			},
-		},
-		{
-			attrs: {
-				label: '审核状态',
-				width: 100,
-				prop: 'flowStatus',
-			},
-			render(flowStatus) {
-				//1审核中 2审核通过 3审核不通过
-				return flowStatus == 1
-					? '审核中'
-					: flowStatus == 2
-					? '审核通过'
-					: '审核不通过'
-			},
-		},
-		{
-			attrs: {
-				label: '启用状态',
-				prop: 'createTime',
-			},
-			render(status) {
-				return status ? '启用' : '禁用'
-			},
-		},
-		{
-			attrs: {
-				label: '操作',
-				width: '200',
-				align: 'right',
-			},
-			// 渲染 el-button,一般用在最后一列。
-			renderHTML(row) {
-				return [
-					{
-						attrs: {
-							label: '修改',
-							type: 'primary',
-							text: true,
-						},
-						el: 'button',
-						click() {
-							getDtl(row)
-						},
-					},
-					// {
-					// 	attrs: {
-					// 		label: '删除',
-					// 		type: 'danger',
-					// 		text: true,
-					// 		disabled:true,
-					// 	},
-					// 	el: 'button',
-					// 	click() {
-					// 		// 弹窗提示是否删除
-					// 		ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', {
-					// 			confirmButtonText: '确定',
-					// 			cancelButtonText: '取消',
-					// 			type: 'warning',
-					// 		})
-					// 			.then(() => {
-					// 				// 删除
-					// 				proxy.post('/tenantInfo/delete', {
-					// 					id: row.id,
-					// 				}).then((res) => {
-					// 					ElMessage({
-					// 						message: '删除成功',
-					// 						type: 'success',
-					// 					})
-					// 					getList()
-					// 				})
-					// 			})
-					// 	},
-					// },
-				]
-			},
-		},
-	]
-})
+  return [
+    {
+      type: "selection",
+      attrs: {
+        label: "多选",
+        prop: "remark",
+      },
+    },
+    {
+      attrs: {
+        label: "企业名称",
+        prop: "enterpriseName",
+      },
+    },
+    {
+      attrs: {
+        label: "租户id",
+        prop: "tenantId",
+        align: "center",
+      },
+    },
+    {
+      attrs: {
+        label: "已创建账号数",
+        prop: "accountCount",
+        align: "center",
+      },
+    },
+    {
+      attrs: {
+        label: "审核状态",
+        width: 100,
+        prop: "flowStatus",
+      },
+      render(flowStatus) {
+        //1审核中 2审核通过 3审核不通过
+        return flowStatus == 1
+          ? "审核中"
+          : flowStatus == 2
+          ? "审核通过"
+          : "审核不通过";
+      },
+    },
+    {
+      attrs: {
+        label: "启用状态",
+        prop: "status",
+      },
+      render(status) {
+        return status ? "启用" : "禁用";
+      },
+    },
+    {
+      attrs: {
+        label: "操作",
+        width: "200",
+        align: "right",
+      },
+      // 渲染 el-button,一般用在最后一列。
+      renderHTML(row) {
+        return [
+          // {
+          //   attrs: {
+          //     label: "修改",
+          //     type: "primary",
+          //     text: true,
+          //   },
+          //   el: "button",
+          //   click() {
+          //     getDtl(row);
+          //   },
+          // },
+          {
+            attrs: {
+              label: row.status == 1 ? "禁用" : "启用",
+              type: "primary",
+              text: true,
+            },
+            el: "button",
+            click() {
+              changeStatus(row);
+            },
+          },
+          // {
+          //   attrs: {
+          //     label: "发布",
+          //     type: "primary",
+          //     text: true,
+          //     bg: true,
+          //   },
+          //   el: "button",
+          //   click() {
+          //     setPublish(row);
+          //   },
+          // },
+
+          // {
+          // 	attrs: {
+          // 		label: '删除',
+          // 		type: 'danger',
+          // 		text: true,
+          // 		disabled:true,
+          // 	},
+          // 	el: 'button',
+          // 	click() {
+          // 		// 弹窗提示是否删除
+          // 		ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', {
+          // 			confirmButtonText: '确定',
+          // 			cancelButtonText: '取消',
+          // 			type: 'warning',
+          // 		})
+          // 			.then(() => {
+          // 				// 删除
+          // 				proxy.post('/tenantInfo/delete', {
+          // 					id: row.id,
+          // 				}).then((res) => {
+          // 					ElMessage({
+          // 						message: '删除成功',
+          // 						type: 'success',
+          // 					})
+          // 					getList()
+          // 				})
+          // 			})
+          // 	},
+          // },
+        ];
+      },
+    },
+  ];
+});
 
 let formData = reactive({
-	data:{},
-	treeData:[],
-})
+  data: {},
+  treeData: [],
+});
 const formOption = reactive({
-	inline: true,
-	labelWidth: 100,
-	itemWidth: 100,
-	rules: [],
-})
-const byform = ref(null)
-const treeData = ref([])
+  inline: true,
+  labelWidth: 100,
+  itemWidth: 100,
+  rules: [],
+});
+const byform = ref(null);
+const treeData = ref([]);
 const formConfig = computed(() => {
-	return [
-		{
-			type: 'input',
-			prop: 'tenantId',
-			label: '租户id',
-			required: true,
-			itemWidth: 100,
-			//disabled:true,
-			itemType: 'text',
-		},
-		{
-			type: 'input',
-			prop: 'enterpriseName',
-			label: '企业名称',
-		},
-		{
-			type: 'radio',
-			prop: 'status',
-			label: '启用状态',
-			border: true,
-			data: [
-				{
-					label: '启用',
-					value: 1,
-				},
-				{
-					label: '禁用',
-					value: 0,
-				},
-			],
-		},
-		{
-			type: 'title',
-			title: '管理员信息',
-		},
-		{
-			type: 'input',
-			itemType: 'password',
-			prop: 'password',
-			label: '密码',
-		},
-	]
-})
+  return [
+    {
+      type: "input",
+      prop: "tenantId",
+      label: "租户id",
+      required: true,
+      itemWidth: 100,
+      //disabled:true,
+      itemType: "text",
+    },
+    {
+      type: "input",
+      prop: "enterpriseName",
+      label: "企业名称",
+    },
+    {
+      type: "radio",
+      prop: "status",
+      label: "启用状态",
+      border: true,
+      data: [
+        {
+          label: "启用",
+          value: 1,
+        },
+        {
+          label: "禁用",
+          value: 0,
+        },
+      ],
+    },
+    {
+      type: "title",
+      title: "管理员信息",
+    },
+    {
+      type: "input",
+      itemType: "password",
+      prop: "password",
+      label: "密码",
+    },
+  ];
+});
 const getList = async (req) => {
-	sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
-	loading.value = true
-	proxy.post('/tenantInfo/page',sourceList.value.pagination).then((message) => {
-		console.log(message)
-		sourceList.value.data = message.rows
-		sourceList.value.pagination.total = message.total
-		setTimeout(() => {
-			loading.value = false
-		}, 200)
-	})
-}
+  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  loading.value = true;
+  proxy
+    .post("/tenantInfo/page", sourceList.value.pagination)
+    .then((message) => {
+      console.log(message);
+      sourceList.value.data = message.rows;
+      sourceList.value.pagination.total = message.total;
+      setTimeout(() => {
+        loading.value = false;
+      }, 200);
+    });
+};
 const openModal = () => {
-	dialogVisible.value = true
-	modalType.value = 'add'
-	formData.data = {}
-	
-}
+  dialogVisible.value = true;
+  modalType.value = "add";
+  formData.data = {};
+};
 const selection = ref({
-	data:[],
-})
+  data: [],
+});
 const select = (_selection, row) => {
-	selection.value.data = _selection
-	console.log(_selection.length)
-}
+  selection.value.data = _selection;
+  console.log(_selection.length);
+};
 const openRoomModal = () => {
-	
-	roomDialogVisible.value = true
-	
-	proxy.get('/tenantInfo/roleMenuTreeSelect/' + selection.value.data[0].tenantId).then((res) => {
-		if(res.code == 200){
-			treeData.value = res.menus
-			formData.treeData = res.checkedKeys
-			tree.value.setCheckedKeys(res.checkedKeys)
-		}
-	})
-	
-}
-const tree = ref(null)
-const submitTree = () => {
-	proxy.post('/tenantInfo/bindingMenu', {
-		tenantId: selection.value.data[0].tenantId,
-		menuIdList: tree.value.getCheckedKeys()
-	}).then((res) => {
-		ElMessage({
-			message: '保存成功',
-			type: 'success',
-		})
-		roomDialogVisible.value = false
-	})
-}
-
+  roomDialogVisible.value = true;
 
+  proxy
+    .get("/tenantInfo/roleMenuTreeSelect/" + selection.value.data[0].tenantId)
+    .then((res) => {
+      if (res.code == 200) {
+        treeData.value = res.menus;
+        formData.treeData = res.checkedKeys;
+        tree.value.setCheckedKeys(res.checkedKeys);
+      }
+    });
+};
+const tree = ref(null);
+const submitTree = () => {
+  proxy
+    .post("/tenantInfo/bindingMenu", {
+      tenantId: selection.value.data[0].tenantId,
+      menuIdList: tree.value.getCheckedKeys(),
+    })
+    .then((res) => {
+      ElMessage({
+        message: "保存成功",
+        type: "success",
+      });
+      roomDialogVisible.value = false;
+    });
+};
 
 const submitForm = () => {
-	console.log(byform.value)
-	byform.value.handleSubmit((valid) => {
-		submitLoading.value = true
-		
-		proxy.post('/tenantInfo/' + modalType.value,formData.data).then((res) => {
-			ElMessage({
-				message: modalType.value == 'add' ? '添加成功' : '编辑成功',
-				type: 'success',
-			})
-			dialogVisible.value = false
-			submitLoading.value = false
-			getList()
-		})
-	})
-}
+  console.log(byform.value);
+  byform.value.handleSubmit((valid) => {
+    submitLoading.value = true;
+
+    proxy.post("/tenantInfo/" + modalType.value, formData.data).then((res) => {
+      ElMessage({
+        message: modalType.value == "add" ? "添加成功" : "编辑成功",
+        type: "success",
+      });
+      dialogVisible.value = false;
+      submitLoading.value = false;
+      getList();
+    });
+  });
+};
 
 const getDtl = (row) => {
-	proxy.post('/tenantInfo/detail', { id: row.id }).then((res) => {
-		formData.data = res
-		console.log(formData)
-		modalType.value = 'edit'
-		dialogVisible.value = true
-	})
-}
+  proxy.post("/tenantInfo/detail", { id: row.id }).then((res) => {
+    formData.data = res;
+    console.log(formData);
+    modalType.value = "edit";
+    dialogVisible.value = true;
+  });
+};
 
-getList()
+const changeStatus = (row) => {
+  modalType.value = "edit";
+  let status = row.status ? 0 : 1;
+  proxy.post("/tenantInfo/detail", { id: row.id }).then((res) => {
+    res.status = status;
+    formData.data = res;
+    ElMessageBox.confirm("你是否确认此操作?", "提示", {
+      confirmButtonText: "确定",
+      cancelButtonText: "取消",
+      type: "warning",
+    }).then(() => {
+      // 删除
+      proxy
+        .post("/tenantInfo/" + modalType.value, formData.data)
+        .then((res) => {
+          ElMessage({
+            message: "操作成功",
+            type: "success",
+          });
+          getList();
+        });
+    });
+  });
+};
+getList();
 </script>
   
 <style lang="scss" scoped>
 .tenant {
-	padding: 20px;
+  padding: 20px;
 }
 </style>

+ 399 - 392
src/views/system/user2/index.vue

@@ -1,431 +1,438 @@
 <template>
-	<div class="user">
-		<div class="tree">
-			<treeList
-				:data="treeListData"
-				v-model="sourceList.pagination.tenantId"
-				node-key="id"
-				@change="treeChange"
-			>
-			</treeList>
-		</div>
-		<div class="content">
-			<byTable
-				:source="sourceList.data"
-				:pagination="sourceList.pagination"
-				:config="config"
-				:loading="loading"
-				highlight-current-row
-				:selectConfig="selectConfig"
-				searchKey="userName"
-				:table-events="{
-					//element talbe事件都能传
-					select: select,
-				}"
-				:action-list="[
-					{
-						text: '添加角色',
-						action: () => openModal('add'),
-                        disabled:!sourceList.pagination.tenantId
-					},
-				]"
-				@get-list="getList"
-			>
-				<template #slotName="{ item }">
-					{{ item.createTime }}
-				</template>
-			</byTable>
-		</div>
-		<el-dialog
-			:title="modalType == 'add' ? '新增' : '编辑'"
-			v-model="dialogVisible"
-			width="500"
-			v-loading="loading"
-		>
-			<byForm
-				:formConfig="formConfig"
-				:formOption="formOption"
-				v-model="formData.data"
-				:rules="rules"
-				ref="byform"
-			>
-                <template #account>
-                    <el-input style="width:150px;margin-right: 10px;" v-model="formData.data.userName" placeholder="请输入用户名"></el-input>
-                    <el-input style="width:150px;margin-right: 10px;" v-model="formData.data.password" placeholder="密码"></el-input>
-                    <span style="color:#409EFF;cursor: pointer;" @click="newPassword">随机生成</span>
-                </template>
-			</byForm>
-			<template #footer>
-				<el-button @click="dialogVisible = false" size="large"
-					>取 消</el-button
-				>
-				<el-button
-					type="primary"
-					@click="submitForm('byform')"
-					size="large"
-					:loading="submitLoading"
-				>
-					确 定
-				</el-button>
-			</template>
-		</el-dialog>
-		<el-dialog
-			title="修改密码"
-			v-model="roomDialogVisible"
-			width="500"
-			:before-close="handleClose"
-			v-loading="loading"
-		>
-			<template #footer>
-				<el-button @click="roomDialogVisible = false" size="large"
-					>取 消</el-button
-				>
-				<el-button
-					type="primary"
-					@click="submitTree('byform')"
-					size="large"
-					:loading="submitLoading"
-				>
-					确 定
-				</el-button>
-			</template>
-		</el-dialog>
-	</div>
+  <div class="user">
+    <div class="tree">
+      <treeList
+        :data="treeListData"
+        v-model="sourceList.pagination.tenantId"
+        node-key="id"
+        @change="treeChange"
+      >
+      </treeList>
+    </div>
+    <div class="content">
+      <byTable
+        :source="sourceList.data"
+        :pagination="sourceList.pagination"
+        :config="config"
+        :loading="loading"
+        highlight-current-row
+        :selectConfig="selectConfig"
+        searchKey="userName"
+        :table-events="{
+          //element talbe事件都能传
+          select: select,
+        }"
+        :action-list="[
+          {
+            text: '添加用户',
+            action: () => openModal('add'),
+            disabled: !sourceList.pagination.tenantId,
+          },
+        ]"
+        @get-list="getList"
+      >
+        <template #slotName="{ item }">
+          {{ item.createTime }}
+        </template>
+      </byTable>
+    </div>
+    <el-dialog
+      :title="modalType == 'add' ? '新增' : '编辑'"
+      v-model="dialogVisible"
+      width="500"
+      v-loading="loading"
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="byform"
+      >
+        <template #account>
+          <el-input
+            style="width: 150px; margin-right: 10px"
+            v-model="formData.data.userName"
+            placeholder="请输入用户名"
+          ></el-input>
+          <el-input
+            style="width: 150px; margin-right: 10px"
+            v-model="formData.data.password"
+            placeholder="密码"
+          ></el-input>
+          <span style="color: #409eff; cursor: pointer" @click="newPassword"
+            >随机生成</span
+          >
+        </template>
+      </byForm>
+      <template #footer>
+        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
+        <el-button
+          type="primary"
+          @click="submitForm('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+    <el-dialog
+      title="修改密码"
+      v-model="roomDialogVisible"
+      width="500"
+      :before-close="handleClose"
+      v-loading="loading"
+    >
+      <template #footer>
+        <el-button @click="roomDialogVisible = false" size="large"
+          >取 消</el-button
+        >
+        <el-button
+          type="primary"
+          @click="submitTree('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+  </div>
 </template>
   
 <script setup>
 /* eslint-disable vue/no-unused-components */
-import { ElMessage, ElMessageBox } from 'element-plus'
-import byTable from '@/components/byTable/index'
-import byForm from '@/components/byForm/index'
-import treeList from '@/components/treeList/index'
-import { computed, defineComponent, ref } from 'vue'
-const loading = ref(false)
-const submitLoading = ref(false)
+import { ElMessage, ElMessageBox } from "element-plus";
+import byTable from "@/components/byTable/index";
+import byForm from "@/components/byForm/index";
+import treeList from "@/components/treeList/index";
+import { computed, defineComponent, ref } from "vue";
+const loading = ref(false);
+const submitLoading = ref(false);
 const sourceList = ref({
-	data: [],
-	pagination: {
-		total: 3,
-		pageNum: 1,
-		pageSize: 10,
-	},
-})
-let dialogVisible = ref(false)
-let modalType = ref('add')
+  data: [],
+  pagination: {
+    total: 3,
+    pageNum: 1,
+    pageSize: 10,
+  },
+});
+let dialogVisible = ref(false);
+let modalType = ref("add");
 let rules = ref({
-	roleKey: [{ required: true, message: '请选择部门', trigger: 'blur' }],
-    nickName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
-    userName:[{ required: true, message: '用户名不能为空', trigger: 'blur' }],
-})
-const { proxy } = getCurrentInstance()
+  roleKey: [{ required: true, message: "请选择部门", trigger: "blur" }],
+  nickName: [{ required: true, message: "姓名不能为空", trigger: "blur" }],
+  userName: [{ required: true, message: "用户名不能为空", trigger: "blur" }],
+});
+const { proxy } = getCurrentInstance();
 const selectConfig = computed(() => {
-	return []
-})
+  return [];
+});
 const config = computed(() => {
-	return [
-		{
-			attrs: {
-				label: '部门',
-				prop: 'deptName',
-			},
-		},
-		{
-			attrs: {
-				label: '姓名',
-				prop: 'nickName',
-				align: 'left',
-			},
-		},
-		{
-			attrs: {
-				label: '用户名',
-				prop: 'userName',
-			},
-		},
-		{
-			attrs: {
-				label: '系统用户',
-				prop: 'userType',
-			},
-			render (userType) {
-				return userType == 1 ? '是' : '否'
-			},
-		},
-		{
-			attrs: {
-				label: '手机号',
-				prop: 'phonenumber',
-			},
-		},
-		{
-			attrs: {
-				label: '工号',
-				prop: 'jobNumber',
-			},
-		},
-		{
-			attrs: {
-				label: '操作',
-				width: '200',
-				align: 'right',
-			},
-			// 渲染 el-button,一般用在最后一列。
-			renderHTML(row) {
-				return [
-					{
-						attrs: {
-							label: '修改',
-							type: 'primary',
-							text: true,
-						},
-						el: 'button',
-						click() {
-							getDtl(row)
-						},
-					},
-					{
-						attrs: {
-							label: '删除',
-							type: 'danger',
-							text: true,
-						},
-						el: 'button',
-						click() {
-							// 弹窗提示是否删除
-							ElMessageBox.confirm(
-								'此操作将永久删除该数据, 是否继续?',
-								'提示',
-								{
-									confirmButtonText: '确定',
-									cancelButtonText: '取消',
-									type: 'warning',
-								}
-							).then(() => {
-								// 删除
-								proxy
-									.post(
-										'/tenantUser/' + row.userId,
-										{
-											id: row.userId,
-										},
-										'delete'
-									)
-									.then((res) => {
-										ElMessage({
-											message: '删除成功',
-											type: 'success',
-										})
-										getList()
-									})
-							})
-						},
-					},
-				]
-			},
-		},
-	]
-})
+  return [
+    {
+      attrs: {
+        label: "部门",
+        prop: "deptName",
+      },
+    },
+    {
+      attrs: {
+        label: "姓名",
+        prop: "nickName",
+        align: "left",
+      },
+    },
+    {
+      attrs: {
+        label: "用户名",
+        prop: "userName",
+      },
+    },
+    {
+      attrs: {
+        label: "系统用户",
+        prop: "userType",
+      },
+      render(userType) {
+        return userType == 1 ? "是" : "否";
+      },
+    },
+    {
+      attrs: {
+        label: "手机号",
+        prop: "phonenumber",
+      },
+    },
+    {
+      attrs: {
+        label: "工号",
+        prop: "jobNumber",
+      },
+    },
+    {
+      attrs: {
+        label: "操作",
+        width: "200",
+        align: "right",
+      },
+      // 渲染 el-button,一般用在最后一列。
+      renderHTML(row) {
+        return [
+          {
+            attrs: {
+              label: "修改",
+              type: "primary",
+              text: true,
+            },
+            el: "button",
+            click() {
+              getDtl(row);
+            },
+          },
+          {
+            attrs: {
+              label: "删除",
+              type: "danger",
+              text: true,
+            },
+            el: "button",
+            click() {
+              // 弹窗提示是否删除
+              ElMessageBox.confirm(
+                "此操作将永久删除该数据, 是否继续?",
+                "提示",
+                {
+                  confirmButtonText: "确定",
+                  cancelButtonText: "取消",
+                  type: "warning",
+                }
+              ).then(() => {
+                // 删除
+                proxy
+                  .post(
+                    "/tenantUser/" + row.userId,
+                    {
+                      id: row.userId,
+                    },
+                    "delete"
+                  )
+                  .then((res) => {
+                    ElMessage({
+                      message: "删除成功",
+                      type: "success",
+                    });
+                    getList();
+                  });
+              });
+            },
+          },
+        ];
+      },
+    },
+  ];
+});
 
 let formData = reactive({
-	data: {},
-})
+  data: {},
+});
 const formOption = reactive({
-	inline: true,
-	labelWidth: 100,
-	itemWidth: 100,
-	rules: [],
-})
-const byform = ref(null)
-const treeListData = ref([])
+  inline: true,
+  labelWidth: 100,
+  itemWidth: 100,
+  rules: [],
+});
+const byform = ref(null);
+const treeListData = ref([]);
 const formConfig = computed(() => {
-	return [
-		{
-			type: 'treeSelect',
-			prop: 'deptId',
-			label: '部门名称',
-			data: [],
-		},
-		{
-			type: 'input',
-			prop: 'nickName',
-			label: '姓名',
-			required: true,
-			itemWidth: 50,
-			//disabled:true,
-			itemType: 'text',
-		},
+  return [
+    {
+      type: "treeSelect",
+      prop: "deptId",
+      label: "部门名称",
+      data: [],
+    },
+    {
+      type: "input",
+      prop: "nickName",
+      label: "姓名",
+      required: true,
+      itemWidth: 50,
+      //disabled:true,
+      itemType: "text",
+    },
+    {
+      type: "slot",
+      prop: "userName",
+      slotName: "account",
+      label: "账户信息",
+    },
+    {
+      type: "radio",
+      prop: "userType",
+      label: "系统用户",
+      required: true,
+      disabled: true,
+      border: true,
+      data: [
         {
-            type: 'slot',
-            prop: 'userName',
-            slotName: 'account',
-            label:"账户信息"
+          label: "是",
+          id: 1,
         },
-		{
-			type: 'radio',
-			prop: 'userType',
-			label: '系统用户',
-			required: true,
-			border: true,
-			data: [
-				{
-					label: '是',
-					id: 1,
-				},
-				{
-					label: '否',
-					id: 0,
-				},
-			],
-		},
-		{
-			type: 'select',
-			label: '角色',
-			prop: 'roleIds',
-            multiple: true,
-			isLoad: {
-				url: '/tenantRole/list?pageNum=1&pageSize=10000',
-				labelKey: 'roleName',
-				labelVal: 'roleId',
-				method: 'get',
-				resUrl: 'rows',
-			},
-		},
-		{
-			type: 'input',
-			prop: 'phonenumber',
-			label: '手机号',
-			required: true,
-			itemWidth: 50,
-			//disabled:true,
-			itemType: 'text',
-		},
-		{
-			type: 'input',
-			prop: 'jobNumber',
-			label: '工号',
-			required: true,
-			itemWidth: 50,
-			//disabled:true,
-			itemType: 'text',
-		},
-	]
-})
+        {
+          label: "否",
+          id: 0,
+        },
+      ],
+    },
+    {
+      type: "select",
+      label: "角色",
+      prop: "roleIds",
+      multiple: true,
+      isLoad: {
+        url: `/tenantRole/list?pageNum=1&pageSize=10000&tenantId=${sourceList.value.pagination.tenantId}`,
+        labelKey: "roleName",
+        labelVal: "roleId",
+        method: "get",
+        resUrl: "rows",
+      },
+    },
+    {
+      type: "input",
+      prop: "phonenumber",
+      label: "手机号",
+      required: true,
+      itemWidth: 50,
+      //disabled:true,
+      itemType: "text",
+    },
+    {
+      type: "input",
+      prop: "jobNumber",
+      label: "工号",
+      required: true,
+      itemWidth: 50,
+      //disabled:true,
+      itemType: "text",
+    },
+  ];
+});
 const newPassword = () => {
-    formData.data.password = generatePassword()
-}
+  formData.data.password = generatePassword();
+};
 const generatePassword = () => {
-    var length = 12,
-      charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
-      password = "";
-    for (var i = 0, n = charset.length; i < length; ++i) {
-        password += charset.charAt(Math.floor(Math.random() * n));
-    }
-    return password;
-}
+  var length = 12,
+    charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
+    password = "";
+  for (var i = 0, n = charset.length; i < length; ++i) {
+    password += charset.charAt(Math.floor(Math.random() * n));
+  }
+  return password;
+};
 
 const getTreeList = () => {
-	proxy.post('/tenantInfo/list').then((message) => {
-		message.map((item) => {
-			item.label = item.enterpriseName
-			item.id = item.tenantId
-			item.children = []
-		})
-		
-		treeListData.value = message
-		console.log(treeListData.value)
-	})
+  proxy.post("/tenantInfo/list").then((message) => {
+    message.map((item) => {
+      item.label = item.enterpriseName;
+      item.id = item.tenantId;
+      item.children = [];
+    });
 
-}
+    treeListData.value = message;
+    console.log(treeListData.value);
+  });
+};
 const getList = async (req) => {
-	sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
-	loading.value = true
-	proxy
-		.get('/tenantUser/list', sourceList.value.pagination)
-		.then((message) => {
-			message.rows.map((item) => {
-				item.deptName = item.dept ? item.dept.deptName : item.dept
-			})
-			sourceList.value.data = message.rows
-			sourceList.value.pagination.total = message.total
-			setTimeout(() => {
-				loading.value = false
-			}, 200)
-		})
-}
+  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  loading.value = true;
+  proxy.get("/tenantUser/list", sourceList.value.pagination).then((message) => {
+    message.rows.map((item) => {
+      item.deptName = item.dept ? item.dept.deptName : item.dept;
+    });
+    sourceList.value.data = message.rows;
+    sourceList.value.pagination.total = message.total;
+    setTimeout(() => {
+      loading.value = false;
+    }, 200);
+  });
+};
 
 const treeChange = (e) => {
-	console.log(e)
-	sourceList.value.pagination.tenantId = e.id
-	getList({ tenantId: e.id })
-}
+  console.log(e);
+  sourceList.value.pagination.tenantId = e.id;
+  getList({ tenantId: e.id });
+};
 
 const openModal = () => {
-	dialogVisible.value = true
-	modalType.value = 'add'
-	formData.data = {}
-}
-const TreetenantId = ref('')
+  dialogVisible.value = true;
+  modalType.value = "add";
+  formData.data = {
+    userType: 1,
+  };
+};
+const TreetenantId = ref("");
 const selection = ref({
-	data: [],
-})
+  data: [],
+});
 const select = (_selection, row) => {
-	selection.value.data = _selection
-	console.log(_selection.length)
-}
+  selection.value.data = _selection;
+  console.log(_selection.length);
+};
 
-const tree = ref(null)
+const tree = ref(null);
 const submitForm = () => {
-	byform.value.handleSubmit((valid) => {
-		const method = modalType.value == 'add' ? 'POST' : 'PUT'
-		console.log(method)
-		proxy
-			.post(
-				'/tenantUser',
-				{
-					...formData.data,
-					tenantId: sourceList.value.pagination.tenantId,
-				},
-				method
-			)
-			.then((res) => {
-				ElMessage({
-					message: modalType.value == 'add' ? '添加成功' : '编辑成功',
-					type: 'success',
-				})
-				dialogVisible.value = false
-				getList()
-			})
-	})
-}
+  byform.value.handleSubmit((valid) => {
+    const method = modalType.value == "add" ? "POST" : "PUT";
+    console.log(method);
+    proxy
+      .post(
+        "/tenantUser",
+        {
+          ...formData.data,
+          tenantId: sourceList.value.pagination.tenantId,
+        },
+        method
+      )
+      .then((res) => {
+        ElMessage({
+          message: modalType.value == "add" ? "添加成功" : "编辑成功",
+          type: "success",
+        });
+        dialogVisible.value = false;
+        getList();
+      });
+  });
+};
 
 const getDept = () => {
-    proxy.get('/system/user/deptTree')
-        .then((res) => {
-            formConfig.value[0].data = res.data
-        })
-}
+  proxy.get("/system/user/deptTree").then((res) => {
+    formConfig.value[0].data = res.data;
+  });
+};
 
 const getDtl = (row) => {
-	formData.data = {...row}
-	modalType.value = 'edit'
-	console.log(modalType.value)
-	dialogVisible.value = true
-}
-getTreeList()
-getList()
-getDept()
+  formData.data = { ...row };
+  modalType.value = "edit";
+  console.log(modalType.value);
+  dialogVisible.value = true;
+};
+getTreeList();
+getList();
+getDept();
 </script>
   
 <style lang="scss" scoped>
 .user {
-	padding: 20px;
-	display: flex;
-	justify-content: space-between;
-	.tree {
-		width: 300px;
-	}
-	.content {
-		width: calc(100% - 320px);
-	}
+  padding: 20px;
+  display: flex;
+  justify-content: space-between;
+  .tree {
+    width: 300px;
+  }
+  .content {
+    width: calc(100% - 320px);
+  }
 }
 </style>