Bladeren bron

封装上下翻页组件

002390 1 jaar geleden
bovenliggende
commit
2e67c85672
3 gewijzigde bestanden met toevoegingen van 99 en 217 verwijderingen
  1. 81 0
      src/components/pageTurning/index.vue
  2. 16 140
      src/views/material/basicFile/details.vue
  3. 2 77
      src/views/material/basicFile/index.vue

+ 81 - 0
src/components/pageTurning/index.vue

@@ -0,0 +1,81 @@
+<script>
+export default {
+  name: "PageTurning",
+  props: {
+    value: {
+      type: [String, Number],
+      required: true,
+    },
+    idList: {
+      type: Array,
+      default: () => [],
+    },
+    size: {
+      type: String,
+      default: "mini",
+    },
+  },
+  data() {
+    return {};
+  },
+  computed: {
+    currentIndex: {
+      get() {
+        let { value, idList } = this.$props;
+        let cIndex = idList.findIndex((item) => item == value);
+        return cIndex;
+      },
+      set() {},
+    },
+    innerList: {
+      get() {
+        return this.$props.idList;
+      },
+      set() {},
+    },
+  },
+  watch: {},
+  methods: {
+    // 上一页
+    Previous() {
+      let { currentIndex } = this;
+      if (currentIndex !== -1) {
+        if (!(currentIndex - 1 < 0)) {
+          // 超出
+        } else {
+          let id = innerList[currentIndex - 1];
+          this.$emit("change", id);
+          this.$emit("input", id);
+          //  this.$emit("update:source", id);
+        }
+      }
+    },
+    // 下一页
+    Down() {
+      let { currentIndex, innerList } = this;
+      if (currentIndex !== -1) {
+        if (currentIndex + 1 === innerList.length) {
+          // 超出
+        } else {
+          //
+          let id = innerList[currentIndex + 1];
+          this.$emit("change", id);
+          this.$emit("input", id);
+        }
+      }
+    },
+  },
+  created() {},
+};
+</script>
+
+<template>
+  <el-button-group>
+    <el-button icon="el-icon-arrow-left" :size="size" @click="Previous"
+      >上一页</el-button
+    >
+    <el-button icon="el-icon-arrow-right" :size="size" @click="Down"
+      >下一页</el-button
+    >
+  </el-button-group>
+</template>

+ 16 - 140
src/views/material/basicFile/details.vue

@@ -60,14 +60,6 @@
                 <el-button :size="size" @click="handleMaterialType"
                   >维护物料类别</el-button
                 >
-                <!-- <el-button
-                  :size="size"
-                  @click="handleIsInvoke"
-                  :key="count"
-                  v-hasPermi="['system:material:add']"
-                >
-                  {{ basicData.value.isEnable == "已启用" ? "停用" : "启用" }}
-                </el-button> -->
               </el-button-group>
             </el-col>
             <el-col :span="1.5">
@@ -1795,10 +1787,8 @@ export default {
 
     // 新增
     handleInster() {
-      this.$notify({
-        title: "警告",
+      this.$notify.warning({
         message: "物料只能通过申请审批增加,不能在节点直接录入!",
-        type: "warning",
       });
     },
     // 除基本信息之后的修改
@@ -1818,10 +1808,8 @@ export default {
           // 查询其他标签页列表详情
           this.getOtherListDetails(activeTab.code, this.otherDeatils.queryKey);
         } else {
-          this.$notify({
-            title: "警告",
+          this.$notify.warning({
             message: "修改请选择单个数据!",
-            type: "warning",
           });
         }
       } else if ("form" === type) {
@@ -1875,10 +1863,8 @@ export default {
             break;
         }
       } else {
-        this.$notify({
-          title: "警告",
+        this.$notify.warning({
           message: "请选择需要删除的数据!",
-          type: "warning",
         });
       }
     },
@@ -1955,15 +1941,12 @@ export default {
     },
     // 刷新
     handleRefresh() {
-      console.log("刷新");
-
       this.$refs.basicMessageRef.clearValidate();
       this.$refs.medcineRef.clearValidate();
       this.handleRest();
     },
     // 维护物料类别
     handleMaterialType() {
-      console.log("维护物料类别");
       this.materialType.show = true;
 
       this.materialType.loading = true;
@@ -1972,20 +1955,6 @@ export default {
         this.getMedcineitemList(this.materialId);
       });
     },
-    // 启用
-    handleIsInvoke(e) {
-      console.log("启用", this.basicData.value.isEnable);
-
-      let param = {
-        isEnable: this.basicData.value.isEnable == "已启用" ? "2" : "0",
-        id: this.basicData.value.id,
-      };
-      console.log(param, "启用/停用param");
-      materialApi.updateEnableMaterial(param).then((res) => {
-        console.log(res, "启用/停用");
-        if (res.code == 200) this.handleRefresh();
-      });
-    },
     // 维护新版本
     handleNewVersion() {
       let _this = this;
@@ -1994,15 +1963,12 @@ export default {
         code: this.basicData.value.code,
       };
       materialApi.versions(data).then((res) => {
-        console.log(res, "维护新版本");
         if (res.code == 200) {
           _this.maintainNewVersion = res.data.result;
           // 维护版本消息展示 by shiy 2023/05/31
           if (!res.data.result) {
-            this.$notify({
-              title: "警告",
+            this.$notify.warning({
               message: res.data.msg,
-              type: "warning",
             });
           }
         }
@@ -2057,7 +2023,6 @@ export default {
     },
     // 物料类别列表选中
     handleSelectionType(list) {
-      console.log("物料类别列表选中", list);
       this.materialType.checkedList = list;
     },
     // 物料类别增删行
@@ -2075,12 +2040,10 @@ export default {
           }
           rowObj["insertId"] = new Date().getTime();
           this.materialType.value.push(rowObj);
-          console.log(this.materialType.value, "物料类别增行rowObj后");
 
           break;
         // 删行
         case "del":
-          console.log("物料类别删行", _this.materialType.checkedList);
           if (_this.materialType.checkedList.length) {
             _this.materialType.checkedList.map((c) => {
               _this.materialType.value = _this.materialType.value.filter(
@@ -2098,10 +2061,8 @@ export default {
               );
             });
           } else {
-            this.$notify({
-              title: "警告",
+            this.$notify.warning({
               message: "请选择需要删除的信息!",
-              type: "warning",
             });
           }
           break;
@@ -2119,13 +2080,11 @@ export default {
             );
             console.log(nullList, "nullList");
             if (!nullList.length && _this.materialType.value.length) {
-              console.log("物料类别保存", _this.materialType.value);
               let params = {
                 materialId: _this.materialId,
                 medcineItems: _this.materialType.value,
               };
               materialApi.medcineitemBatchSave(params).then((res) => {
-                console.log(res, "保存物料类型");
                 if (res.code == 200) {
                   _this.materialType.isEdit = false;
                   _this.handleMaterialTypeRow();
@@ -2133,26 +2092,20 @@ export default {
               });
               // 保存
             } else {
-              this.$notify({
-                title: "警告",
+              this.$notify.warning({
                 message: "不能保存空数据或存在数据为空!",
-                type: "warning",
               });
             }
           } else {
             // 非编辑状态
-            console.log("物料类别修改");
             this.materialType.isEdit = true;
           }
           break;
         // 刷新
         default:
-          console.log("物料类别刷新");
           if (this.materialType.isEdit) {
-            this.$notify({
-              title: "警告",
+            this.$notify.warning({
               message: "请先保存数据!",
-              type: "warning",
             });
           } else {
             this.materialType.loading = true;
@@ -2166,22 +2119,14 @@ export default {
     },
     // 物料类别弹窗关闭前
     handleCloseTypeDetails(done) {
-      console.log("物料类别弹窗关闭前");
       this.materialType.isEdit
-        ? this.$notify({
-            title: "警告",
+        ? this.$notify.warning({
             message: "请先保存数据!",
-            type: "warning",
           })
         : done();
     },
-    // 保存修改并新增
-    handleSaveAdd() {
-      console.log("保存修改并新增");
-    },
     // 其他标签页弹窗取消操作
     handleOtherCancel() {
-      console.log("其他标签页弹窗取消操作");
       this.optionDialog.show = true;
       this.optionDialog.op = "修改";
     },
@@ -2222,13 +2167,10 @@ export default {
     },
     // 其他页签详情弹窗关闭事件
     handleCloseOtherDetails(done) {
-      console.log("其他页签详情弹窗关闭事件");
       // 处于编辑状态
       if (this.otherDeatils.isEdit) {
-        this.$notify({
-          title: "警告",
+        this.$notify.warning({
           message: "请先退出编辑操作",
-          type: "warning",
         });
       } else {
         this.handleOtherListRefresh();
@@ -2401,10 +2343,8 @@ export default {
             );
             console.log(drug, "drug------------------------------------");
             if (drug.length) {
-              _this.$notify({
-                title: "警告",
+              _this.$notify.warning({
                 message: "不能维护相同的物料类别!",
-                type: "warning",
               });
               confirm = false;
             } else {
@@ -2527,10 +2467,8 @@ export default {
         if (code == 200) {
           this.otherDeatils.isEdit = false;
           this.handleOtherRefresh();
-          this.$notify({
-            title: "成功",
+          this.$notify.success({
             message: msg,
-            type: "success",
           });
         }
       } catch (error) {
@@ -2558,10 +2496,8 @@ export default {
         if (code == 200) {
           this.otherDeatils.isEdit = false;
           this.handleOtherRefresh();
-          this.$notify({
-            title: "成功",
+          this.$notify.success({
             message: msg,
-            type: "success",
           });
         }
       } catch (error) {
@@ -2586,10 +2522,8 @@ export default {
         if (code == 200) {
           this.otherDeatils.isEdit = false;
           this.handleOtherRefresh();
-          this.$notify({
-            title: "成功",
+          this.$notify.success({
             message: msg,
-            type: "success",
           });
         }
       } catch (error) {
@@ -2614,10 +2548,8 @@ export default {
         if (code == 200) {
           this.otherDeatils.isEdit = false;
           this.handleOtherRefresh();
-          this.$notify({
-            title: "成功",
+          this.$notify.success({
             message: msg,
-            type: "success",
           });
         }
       } catch (error) {
@@ -2643,10 +2575,8 @@ export default {
         if (code == 200) {
           this.otherDeatils.isEdit = false;
           this.handleOtherRefresh();
-          this.$notify({
-            title: "成功",
+          this.$notify.success({
             message: msg,
-            type: "success",
           });
         }
       } catch (error) {
@@ -2671,10 +2601,8 @@ export default {
         if (code == 200) {
           this.otherDeatils.isEdit = false;
           this.handleOtherRefresh();
-          this.$notify({
-            title: "成功",
+          this.$notify.success({
             message: msg,
-            type: "success",
           });
         }
       } catch (error) {
@@ -2691,7 +2619,6 @@ export default {
 
     judgeIsRequriedByProps(message) {
       // condiition:条件,tergetNames:目标porps数组,formName:表单,formRef:表单ref名,
-
       this[message.formName].form.forEach((formItem) => {
         let target = message.tergetNames.filter((t) => t === formItem.prop);
 
@@ -2720,9 +2647,6 @@ export default {
       });
       // 医疗行业
       await this.getTagList("material_medcine", async (form) => {
-        // form.forEach((item) => {
-        //   this.medcineData.value[item.prop] = ''
-        // })
         this.medcineData.form = [...form];
         this.medcineData.value = initParams(this.medcineData.form, "prop");
         this.medcineRules = initRules(form);
@@ -2758,29 +2682,7 @@ export default {
       },
       deep: true,
     },
-    // 通过一级分类判断业务线是否必填
-    // "basicData.value.oneClass": {
-    //   handler(nVal, oVal) {
-
-    //     this.basicData.form = this.basicData.form.map(formItem => {
 
-    //       if (formItem.prop === "businessLine" && nVal) {
-
-    //         if ( nVal.includes('介入耗材&5') || nVal.includes('骨科耗材&2') ||
-    //             nVal.includes('普通耗材&3') || nVal.includes('医用设备&1') ||
-    //             nVal.includes('体外诊断&4')) {
-
-    //               formItem.required  = true
-    //         } else {
-    //           formItem.required  = false
-    //         }
-
-    //       }
-    //       return formItem;
-    //     })
-    //   },
-    //   deep: true,
-    // },
     // 物料分类改变同时改变一二三级分类
     "basicData.value.classifyId": {
       async handler(nVal, oVal) {
@@ -2822,7 +2724,6 @@ export default {
   },
 
   created() {
-    console.log(this, "created");
     // 基本信息
     this.handleRest();
     if (window.name === "") {
@@ -2855,8 +2756,6 @@ export default {
   }
 
   .md-content {
-    // margin-top: 12px;
-    // height: calc(100vh - 260px);
     // height: calc(100vh - 200px);
     box-sizing: border-box;
 
@@ -2864,13 +2763,8 @@ export default {
       overflow: auto;
 
       .md-main {
-        // height: calc(100vh - 625px);
         margin-bottom: 10px;
 
-        .el-table__body {
-          // height: calc(100vh - 300px);
-        }
-
         .el-form {
           max-height: 430px;
           overflow-y: auto;
@@ -2901,9 +2795,6 @@ export default {
     }
   }
 
-  // .md-content>.el-tabs {
-  //   height: calc(100vh - 280px);
-  // }
 
   .otherDialog {
     .el-collapse-item__content {
@@ -2930,9 +2821,6 @@ export default {
       overflow-x: hidden;
     }
 
-    // .el-dialog__header {
-    //   background-color: rgb(244, 244, 244);
-    // }
   }
 
   .el-dialog__header {
@@ -3084,16 +2972,4 @@ export default {
 >>> .referTree {
   margin-top: 10px;
 }
-
-/* .md-main>>>.el-table .el-table__body {
-    height: calc(100vh - 300px);
-  } */
-
-/* .otherDialog>>>.el-collapse-item__content {
-    padding-bottom: 12px;
-  }
-
-  .otherDialog>>>.el-dialog__body {
-    padding: 12px 20px;
-  } */
 </style>

+ 2 - 77
src/views/material/basicFile/index.vue

@@ -46,14 +46,6 @@
             :select-data="checkedList"
             @success="handleQuery"
           ></is-using>
-          <!-- <el-button
-              :size="size"
-              @click="handleIsInvoke"
-              :disabled="checkedList.length != 1"
-              v-hasPermi="['system:material:add']"
-            >
-              {{ handleJudgeIsUsing() ? "停用" : "启用" }}
-            </el-button> -->
         </el-col>
 
         <!-- 导入导出 -->
@@ -97,7 +89,6 @@
           :height="tableHeight"
           ref="materialTable"
           @cell-dblclick="handledbClick"
-          @selection-change="handleSelectionChange"
           @select="handleSelect"
           @select-all="handleSelectAll"
           :header-row-style="{
@@ -350,14 +341,6 @@ export default {
       );
     },
 
-    // 新增
-    handleInster() {
-      this.$notify({
-        title: "警告",
-        message: "物料只能通过申请审批增加,不能在节点直接录入!",
-        type: "warning",
-      });
-    },
     // 修改
     handleEdit() {
       if (this.checkedList.length == 1) {
@@ -368,14 +351,12 @@ export default {
           },
         });
       } else {
-        this.$notify({
-          title: "警告",
+        this.$notify.warning({
           message: `${
             this.checkedList.length > 1
               ? "修改只能选择单个数据!"
               : "请选择需要修改的信息!"
           }`,
-          type: "warning",
         });
       }
     },
@@ -394,17 +375,11 @@ export default {
           }
         });
       } else {
-        this.$notify({
-          title: "警告",
+        this.$notify.warning({
           message: `请选择需要删除的数据!`,
-          type: "warning",
         });
       }
     },
-    // 复制
-    handleCopy() {
-      console.log("复制");
-    },
     //查询
     handleQuery() {
       // 重新查询后需要清空列表选中的数据
@@ -414,10 +389,6 @@ export default {
     },
     // 重置查询条件
     handleResetQuery() {
-      // for (const key in this.queryForm) {
-
-      //   this.queryForm[key] = '';
-      // }
 
       this.queryParams.pageNum = 1;
 
@@ -435,30 +406,6 @@ export default {
       // }
     },
 
-    // 启用/停用
-    handleIsInvoke() {
-      // true   当前状态为启用,需要改为停用
-      // 0:启用  2:停用
-      let param = {
-        isEnable: this.handleJudgeIsUsing() ? "2" : "0",
-        id: this.checkedList[0].id,
-      };
-      materialApi.updateEnableMaterial(param).then((res) => {
-        if (res.code == 200) {
-          this.handleRefresh();
-          // 清空选中数据
-          this.checkedList = [];
-          this.$refs.materialTable.clearSelection();
-        }
-      });
-    },
-    isInvoke(val) {
-      return val;
-    },
-    // 申请单查询
-    handleQueryForm() {
-      console.log("申请单查询");
-    },
     // 批量导入
     handleImport() {
       this.importData.show = true;
@@ -618,11 +565,6 @@ export default {
       const res = new Map();
       return arr.filter((arr) => !res.has(arr[key]) && res.set(arr[key], 1));
     },
-    // 选中数据改变
-    handleSelectionChange(list) {
-      // this.checkedList = this.handleUnique([...this.checkedList, ...list], 'id');
-      // this.$emit('headerOption', JSON.stringify({ checkedList: [... this.checkedList] }))
-    },
     // 行数据勾选操作
     handleSelect(selection, row) {
       this.checkedList = selection;
@@ -688,23 +630,6 @@ export default {
       materialApi.tagList({ templateCode }).then((res) => {
         console.log(res, "获取物料列表表头");
         if (res.code == 200) {
-          // let dictList = []
-          // res.data.forEach(item =>{
-          //   if(item.dictId){
-          //     // 字典
-          //     dictList.push({
-          //       item:{...item},
-          //       attr:{
-          //         dictName:item.dictId
-          //       }
-          //     });
-
-          //   }
-          // })
-          // console.log(dictList,'dictList');
-          // console.log(this,'this');
-          // this.dict =[...initDicts([...SearchColumns,...dictList])]
-
           this.tableHeader = res.data;
         }
       });