wangting
2025-01-15 a0d36d46fcc10b52408ecd12d0cb319b35d7bd03
Source/plt-web/plt-web-ui/src/views/processTemplate/customDefine/index.vue
@@ -20,12 +20,104 @@
        查询
      </el-button>
    </div>
    <div>
      <el-main>
        <basic-container>
          <avue-crud
            ref="userCrud"
            :data="tableData"
            :option="option"
            :table-loading="tableLoading"
            @on-load="getTableList"
            @refresh-change="handleRefresh"
            @search-change="handleSearch"
            @search-reset="handleReset"
            @selection-change="selectChange"
            @row-click="rowClickHandler"
          >
            <template slot="menuLeft" slot-scope="scope">
              <el-button v-if="permissionList.addBtn" class="button-custom-icon" plain size="small" type="primary"
                         @click="rowSaveHandlerClick">
                <icon-show :name="permissionList.addBtn.source"></icon-show>
                创建
              </el-button>
              <el-button v-if="permissionList.delBtn" class="button-custom-icon" plain size="small" type="danger"
                         @click="allDelHandler">
                <icon-show :name="permissionList.delBtn.source"></icon-show>
                删除
              </el-button>
              <el-button v-if="permissionList.viewTheScopeBtn" class="button-custom-icon" plain size="small"
                         type="primary"
                         @click="chekView">
                <icon-show :name="permissionList.viewTheScopeBtn.source"></icon-show>
                查看使用范围
              </el-button>
              <el-button v-if="permissionList.downloadImportTemplateBtn" class="button-custom-icon" plain size="small"
                         type="primary" @click="downloadTemplateHandler">
                <icon-show :name="permissionList.downloadImportTemplateBtn.source"></icon-show>
                下载导入模板
              </el-button>
              <el-button v-if="permissionList.importBtn" class="button-custom-icon" plain size="small" type="primary"
                         @click="uploadUser">
                <icon-show :name="permissionList.importBtn.source"></icon-show>
                导入
              </el-button>
              <el-button v-if="permissionList.exportBtn" class="button-custom-icon" plain size="small" type="primary"
                         @click="downloadHandler">
                <icon-show :name="permissionList.exportBtn.source"></icon-show>
                导出
              </el-button>
            </template>
            <template slot="menu" slot-scope="scope">
              <el-button v-if="permissionList.editBtn" size="small" type="text"
                         @click="editBtnClick(scope.row)">
                <icon-show :name="permissionList.editBtn.source"></icon-show>
                编辑
              </el-button>
              <el-button v-if="permissionList.delBtn" size="small" type="text"
                         @click="rowDeleteHandler(scope.row)">
                <icon-show :name="permissionList.delBtn.source"></icon-show>
                删除
              </el-button>
            </template>
          </avue-crud>
          <!-- 创建编辑自定义对话框    -->
          <el-dialog
            v-dialogDrag
            v-loading="dialogLoading"
            :title="dialogType === 'add' ? ' 创建' : '编辑'"
            :visible.sync="dialogVisible"
            append-to-body="true"
            class="avue-dialog"
            width="1000px"
            @close="dialogClose"
          >
            <span slot="footer" class="dialog-footer">
              <el-button size="small" type="primary" @click="rowSaveHandler">确 定</el-button>
              <el-button size="small" @click="dialogVisible = false">取 消</el-button>
            </span>
          </el-dialog>
        </basic-container>
      </el-main>
      <el-aside width="35%">
        <basic-container>
        </basic-container>
      </el-aside>
    </div>
  </basic-container>
</template>
<script>
import {mapGetters} from "vuex";
import basicOption from "@/util/basic-option";
import {deleteType, getTypeList, saveType, updateType} from "@/api/processTemplate/type";
import {getProcessTempList,saveProcessTemp,updateProcessTemp,deleteProcessTemp} from "@/api/processTemplate/define";
import func from "@/util/func";
export default {
  name: "index",
@@ -85,11 +177,90 @@
  },
  methods:{
    getTableList(){
      this.tableLoading = true;
      getProcessTempList().then(res => {
        this.tableData = res.data.data;
        this.tableLoading = false;
      })
    },
    //流程分类选择
    tempTypeChange(val){
      this.getTableList();
    }
    },
    // 新增
    saveHandler(row, done, loading) {
      saveProcessTemp(row).then(res => {
        if (res.data.code === 200) {
          this.$message.success(res.data.obj);
          this.getTableList();
          done();
        }
      }).catch(err => {
        loading()
      });
    },
    handleEdit(row,index){
      this.$refs.crud.rowEdit(row, index);
    },
    // 编辑
    updateHandler(row, index, done, loading) {
      updateProcessTemp(row).then(res => {
        if (res.data.code === 200) {
          this.$message.success(res.data.obj);
          this.getTableList();
          done()
        }
      }).catch(err => {
        loading()
      });
    },
    // 删除
    handleDel(row,index) {
      let params = {
        ids: row.id
      }
      this.$confirm('您确定要删除当前数据吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteProcessTemp(params).then(res => {
          if (res.data.code === 200) {
            this.$message.success(res.data.obj);
            this.getTableList();
          }
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    //选择的行
    selectionChange(list) {
      this.selectionList = list;
    },
    // 行单选
    rowClickHandler(row) {
      func.rowClickHandler(
        row,
        this.$refs.crud,
        this.lastIndex,
        (newIndex) => {
          this.lastIndex = newIndex;
        },
        () => {
          this.selectionList = [row];
        }
      );
    },
  }
}
</script>