wenhongquan hace 2 años
padre
commit
d768a63f7e
Se han modificado 2 ficheros con 32 adiciones y 7 borrados
  1. 5 6
      src/components/Public/table.vue
  2. 27 1
      src/views/car/carInfo/index.vue

+ 5 - 6
src/components/Public/table.vue

@@ -36,8 +36,11 @@
           <!-- {{ eval(item.prop)}} -->
         </span>
       </template>
+      <template #default="scope" v-if="item.custom">
+        <component :is="item.render(scope.row)"></component>
+      </template>
     </el-table-column>
-    <el-table-column label="操作" v-show="showButton">
+    <el-table-column label="操作" v-if="showButton">
       <template #default="scope">
         <div v-show="showButton">
           <el-button v-for="button in buttons" :key="button.text" :type="button.type" link @click="clickbutton(button.func, scope.row)">{{ button.text
@@ -49,8 +52,6 @@
 </template>
 
 <script setup lang="ts">
-import { getType } from 'vue-types/dist/utils';
-
 const { proxy } = getCurrentInstance() as ComponentInternalInstance
 const { energy_type, business_type,tbl_car_type } = toRefs<any>(proxy?.useDict("energy_type", "business_type","tbl_car_type"));
 
@@ -85,9 +86,7 @@ const getRowData = (rowdata, column) => {
       return tbl_car_type.value.filter(i=>i.value == rowdata[column.prop])[0].label
     }
   }
-  } catch (error) {
-
-  }
+  } catch (error) {}
   return "";
 
 }

+ 27 - 1
src/views/car/carInfo/index.vue

@@ -42,7 +42,7 @@
 
     <el-card shadow="never">
 
-      <tableElm :columns="columns" @childToParent='childrenClick' ref="table"></tableElm>
+      <tableElm :columns="columns" @childToParent='childrenClick'  :showButton="false" ref="table"></tableElm>
 
       <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
         v-model:limit="queryParams.pageSize" @pagination="getList" />
@@ -62,6 +62,7 @@
       </template>
     </el-dialog>
   </div>
+
 </template>
 
 <script setup name="CarInfo" lang="ts">
@@ -70,6 +71,8 @@ import { CarInfoVO, CarInfoQuery, CarInfoForm } from '@/api/carInfo/types';
 import tableElm from "@/components/Public/table.vue";
 import { useRoute, useRouter } from "vue-router";
 import useTagsViewStore from '@/store/modules/tagsView';
+import { h } from 'vue';
+import { ElButton,ElMessage } from 'element-plus'
 
 const route = useRoute();
 const router = useRouter();
@@ -102,6 +105,29 @@ const columns = ref([
   { label: '车辆分类', prop: 'carType', pprop: "ext1", visible: true, isTemplate: false, isTemplateJson: false ,dict:"tbl_car_type"},
   { label: '网格', prop: 'wangge', pprop: "ext1", visible: true, isTemplate: false, isTemplateJson: true },
   { label: '单位', prop: 'dept', pprop: "ext1", visible: true, isTemplate: false, isTemplateJson: true },
+  {
+    label: '操作', custom: true, visible: true, render: (data) => {
+
+      return h('div',[h(ElButton, {
+        type: 'primary', // 组件属性
+        link:true,
+        onClick: () => {
+          handleUpdate(data)
+        },
+      },'管理'),h(ElButton, {
+        type: 'danger', // 组件属性
+        link:true,
+        onClick: () => {
+          handleDelete(data)
+        },
+      },'删除')].concat(data.carType==1?[h(ElButton, {
+        type: 'primary', // 组件属性
+        link:true,
+        onClick: () => {
+          ElMessage.success("sss")
+        },
+      },'查看地图')]:[])) ;
+  } },
 ])
 
 const initFormData: CarInfoForm = {