yangfeng
2024-03-04 e314f30de574edeb86f27555c275545b7d12b3a0
生丝定级标准页面开发、添加列及添加列输入框、删除列功能开发
2个文件已修改
185 ■■■■■ 已修改文件
src/views/systemSetting/silkStandardSetting/components/silkTableList.vue 123 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/systemSetting/silkStandardSetting/index.vue 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/systemSetting/silkStandardSetting/components/silkTableList.vue
@@ -1,5 +1,7 @@
<template>
  <div class="page-view">
    <div class="top-box">
      <div class="table-box" :style="{ width: detailEnter ? '95%' : '100%' }">
    <el-form ref="form" :model="tableList" :show-message="false" label-position="right">
      <el-table
        ref="fromTable"
@@ -12,7 +14,13 @@
      >
        <el-table-column v-if="selectBox" type="selection" :reserve-selection="true" width="40" align="center">
        </el-table-column>
        <el-table-column v-if="tableList.isReturn" type="index" label="#" width="50" align="center"></el-table-column>
            <el-table-column
              v-if="tableList.isReturn"
              type="index"
              label="#"
              width="50"
              align="center"
            ></el-table-column>
        <el-table-column
          v-for="(item, i) in tableList.tableColumn"
          :key="i"
@@ -25,7 +33,23 @@
          <!-- 表头样式 -->
          <template slot="header">
            <span v-if="item.isRequird" style="color: #f56c6c">*</span>
            <span>{{ item.label }}</span>
                <div v-else-if="item.addColumn" class="add-column-box">
                  <el-input
                    placeholder="请输入"
                    v-model="item.label"
                    size="mini"
                    clearable
                    @change="
                      (val) => {
                        addColumnInputChange(val, item.prop)
                      }
                    "
                  ></el-input>
                  <div class="common-select-btn" @click="clearupColumn(item.prop)">
                    <i class="el-icon-remove" title="删除"></i>
                  </div>
                </div>
                <span v-else>{{ item.label }}</span>
          </template>
          <!-- column样式 -->
          <template slot-scope="scope">
@@ -141,7 +165,7 @@
            <span v-else style="text-align: right">{{ scope.row[item.prop] }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="80" v-if="detailEnter" align="center">
            <el-table-column label="操作" width="80" v-if="!detailEnter" align="center">
          <template slot-scope="scope">
            <el-button type="text" size="small" :disabled="!isOperate" @click="deleteClick(scope)">删除</el-button>
          </template>
@@ -152,8 +176,18 @@
        </div>
      </el-table>
    </el-form>
      </div>
      <div
        v-if="detailEnter"
        class="add-column-box"
        @click="addColumnClick"
        :style="{ width: detailEnter ? '40px' : '0px' }"
      >
        <i class="el-icon-circle-plus"></i>
      </div>
    </div>
    <div v-if="detailEnter" style="margin: 10px">
      <div class="add-btn-box" @click="add">
      <div class="add-btn-box" @click="addRowClick">
        <i class="el-icon-circle-plus"></i>
      </div>
      <!-- <el-button size="small" type="primary" :disabled="!isOperate" @click="add">新增</el-button> -->
@@ -249,29 +283,13 @@
        this.isRecalculate = true
      }
    },
    // 产品名称
    // async getProductList() {
    //   await getProductList({
    //     productName: "",
    //     productNumber: "",
    //     page: 1,
    //     pageSize: 100
    //   }).then((res) => {
    //     console.log(res, "产品名称")
    //     if (res.code === 200) {
    //       if (res.data.data && res.data.data.length > 0) {
    //         this.productList = res.data.data
    //       }
    //     }
    //   })
    // },
    // 多选
    handleSelectionChange(val) {
      this.$emit("getSelectArray", val)
    },
    // 新增
    add() {
    addRowClick() {
      if (this.addTypeIdMultiple) {
        this.projectIndex = this.tableList.tableData.length
        this.editSelCommonConfig.title = "产品名称"
@@ -286,31 +304,31 @@
    },
    // 删除
    deleteClick(scope) {
      this.tableList.tableData.splice(scope.$index, 1)
      this.$forceUpdate()
      this.$message.success("删除成功!")
      this.$emit("deleteClick", scope)
    },
    // 新增
    selClientClick(scope, prop) {
      console.log(scope, prop)
      this.projectIndex = scope.$index
      this.editSelCommonConfig.title = "产品名称"
      this.editSelCommonConfig.isSelectBox = true
      this.editSelCommonConfig.editVisible = true
    },
    // 编辑
    handleEditClient(scope, prop) {
      console.log(scope, prop)
      this.projectIndex = scope.$index
      this.editSelCommonConfig.title = "产品名称"
      this.editSelCommonConfig.isSelectBox = false
      this.editSelCommonConfig.editVisible = true
      this.$emit("clearupProject", this.tableList.tableData, scope.$index)
    },
    // 删除
    clearupClient(scope) {
      this.$emit("clearupProject", this.tableList.tableData, scope.$index)
    },
    // 添加列按钮
    addColumnClick() {
      this.$emit("addColumnClick")
    },
    // 添加列头部标题输入
    addColumnInputChange(val, prop) {
      console.log(val, prop, "添加列头部标题输入")
    },
    // 删除列
    clearupColumn(prop) {
      console.log(prop)
      this.$emit("clearupColumn", prop)
    }
  },
  //解决表格抖动问题
  beforeUpdate() {
    this.$nextTick(() => {
      this.$refs["fromTable"].doLayout()
    })
  }
}
</script>
@@ -318,6 +336,10 @@
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.page-view {
  .top-box {
    display: flex;
    .table-box {
      flex: 1;
  .el-form-item {
    margin-bottom: 0;
    .custom-name {
@@ -330,12 +352,31 @@
      }
    }
  }
    }
    .add-column-box {
      // width: 40px;
      margin-top: 10px;
      font-size: 26px;
      color: #5582f3;
      margin-left: 20px;
      cursor: pointer;
    }
  }
  .add-btn-box {
    font-size: 26px;
    color: #5582f3;
    margin-left: 50px;
    cursor: pointer;
  }
  .add-column-box {
    display: flex;
    .common-select-btn {
      margin-left: 5px;
      font-size: 18px;
      cursor: pointer;
      color: #ff0000;
    }
  }
}
::v-deep {
  .el-form-item__label {
src/views/systemSetting/silkStandardSetting/index.vue
@@ -3,7 +3,7 @@
    <div class="filter-card">
      <CommonSearch :show-add="false" :amount-view="false" placeholder="请输入关键词" @searchClick="onFilterSearch">
        <template slot="leftButton">
          <el-button size="small" type="primary" @click="addBtnClick">新增</el-button>
          <el-button size="small" type="primary" @click="addBtnClick" :disabled="!isEdit">新增</el-button>
          <el-button size="small" type="primary" @click="refreshClick">刷新</el-button>
          <el-button size="small" type="primary" @click="printClick">打印</el-button>
        </template>
@@ -24,6 +24,8 @@
          @addProjectClick="addBtnClick"
          @clearupProject="clearupProject"
          @deleteClick="clearupProject"
          @addColumnClick="addColumnClick"
          @clearupColumn="clearupColumn"
        >
        </SilkTableList>
      </div>
@@ -43,7 +45,24 @@
    return {
      isEdit: false,
      silkTableList: {},
      tableData: []
      tableData: [],
      tableColumn: [
        { label: "检查项目名称", prop: "projectName", projectName: true },
        { label: "开始纤度", prop: "start", inputFloat: true },
        { label: "结束纤度", prop: "end", inputFloat: true },
        { label: "野纤", prop: "price1", inputFloat: true },
        { label: "大野", prop: "price2", inputFloat: true },
        { label: "特野", prop: "price3", inputFloat: true }
      ],
      columnNum: 0,
      dataObj: {
        projectName: "",
        start: 0,
        end: 0,
        price1: 0,
        price2: 0,
        price3: 0
      }
    }
  },
  created() {
@@ -54,14 +73,7 @@
      this.silkTableList = {
        tableData: this.tableData,
        isReturn: false,
        tableColumn: [
          { label: "检查项目名称", prop: "projectName", projectName: true },
          { label: "开始纤度", prop: "start", inputFloat: true },
          { label: "结束纤度", prop: "end", inputFloat: true },
          { label: "野纤", prop: "price1", inputFloat: true },
          { label: "大野", prop: "price2", inputFloat: true },
          { label: "特野", prop: "price3", inputFloat: true }
        ]
        tableColumn: this.tableColumn
      }
    },
    // 搜索
@@ -70,14 +82,7 @@
    },
    // 新增
    addBtnClick() {
      this.tableData.push({
        projectName: "",
        start: 0,
        end: 0,
        price1: 0,
        price2: 0,
        price3: 0
      })
      this.tableData.push(this.dataObj)
    },
    // 刷新
    refreshClick() {},
@@ -95,6 +100,27 @@
    // 保存编辑按钮切换
    editSaveClick() {
      this.isEdit = !this.isEdit
    },
    // 添加列
    addColumnClick() {
      let propStr = "trends" + this.columnNum
      this.tableColumn.splice(2, 0, { label: "", prop: propStr, inputFloat: true, addColumn: true })
      this.$set(this.dataObj, propStr, 0)
      console.log(this.tableColumn)
      this.silkTableList.tableColumn = this.tableColumn
      this.columnNum += 1
    },
    // 删除列
    clearupColumn(prop) {
      let currentIndex = 0
      this.tableColumn.map((item, index) => {
        if (item.prop == prop) {
          currentIndex = index
        }
      })
      this.tableColumn.splice(currentIndex, 1)
      this.silkTableList.tableColumn = this.tableColumn
      this.$delete(this.dataObj, prop)
    }
  }
}