yxh
2023-03-21 76bd95ca79b03b84f6d011a81794aabcdeef169b
ruoyi-ui/src/views/smartor/svytitle/index1.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,230 @@
<template>
     <el-container>
      <el-aside width="200px">
        <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
      </el-aside>
      <el-main>
        <div is='dw_topic' />
      </el-main>
    </el-container>
 </template>
<script>
import { listSvytitle, getSvytitle, delSvytitle, addSvytitle, updateSvytitle } from "@/api/smartor/svytitle";
export default {
  name: "Svytitle",
  data() {
    return {
      // é®ç½©å±‚
      loading: true,
      // é€‰ä¸­æ•°ç»„
      ids: [],
      // éžå•个禁用
      single: true,
      // éžå¤šä¸ªç¦ç”¨
      multiple: true,
      // æ˜¾ç¤ºæœç´¢æ¡ä»¶
      showSearch: true,
      // æ€»æ¡æ•°
      total: 0,
      // é—®å·è¡¨æ ¼æ•°æ®
      svytitleList: [],
      // å¼¹å‡ºå±‚标题
      title: "",
      // æ˜¯å¦æ˜¾ç¤ºå¼¹å‡ºå±‚
      open: false,
      // æŸ¥è¯¢å‚æ•°
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        categoryid: null,
        svycode: null,
        svyname: null,
        description: null,
        introduce: null,
        submitprompt: null,
        templateid: null,
        version: null,
        centerlibrarycode: null,
        centerlibraryid: null,
        islocal: null,
        isenable: null,
        orgid: null,
        isupload: null,
        uploadTime: null
      },
      // è¡¨å•参数
      form: {},
      // è¡¨å•校验
      rules: {
        delFlag: [
          { required: true, message: " åˆ é™¤æ ‡è®° ä¸èƒ½ä¸ºç©º", trigger: "blur" }
        ],
        isupload: [
          { required: true, message: " ä¸Šä¼ æ ‡è®° ä¸èƒ½ä¸ºç©º", trigger: "blur" }
        ],
      },
      data: [{
        label: '一级 1',
        children: [{
          label: '二级 1-1',
          children: [{
            label: '三级 1-1-1'
          }]
        }]
      }, {
        label: '一级 2',
        children: [{
          label: '二级 2-1',
          children: [{
            label: '三级 2-1-1'
          }]
        }, {
          label: '二级 2-2',
          children: [{
            label: '三级 2-2-1'
          }]
        }]
      }, {
        label: '一级 3',
        children: [{
          label: '二级 3-1',
          children: [{
            label: '三级 3-1-1'
          }]
        }, {
          label: '二级 3-2',
          children: [{
            label: '三级 3-2-1'
          }]
        }]
      }],
      defaultProps: {
        children: 'children',
        label: 'label'
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** æŸ¥è¯¢é—®å·åˆ—表 */
    getList() {
      this.loading = true;
      listSvytitle(this.queryParams).then(response => {
        this.svytitleList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // å–消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // è¡¨å•重置
    reset() {
      this.form = {
        svyid: null,
        categoryid: null,
        svycode: null,
        svyname: null,
        description: null,
        introduce: null,
        submitprompt: null,
        templateid: null,
        version: null,
        centerlibrarycode: null,
        centerlibraryid: null,
        islocal: null,
        isenable: null,
        orgid: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        isupload: null,
        uploadTime: null
      };
      this.resetForm("form");
    },
    /** æœç´¢æŒ‰é’®æ“ä½œ */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** é‡ç½®æŒ‰é’®æ“ä½œ */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // å¤šé€‰æ¡†é€‰ä¸­æ•°æ®
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.svyid)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** æ–°å¢žæŒ‰é’®æ“ä½œ */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加问卷";
    },
    /** ä¿®æ”¹æŒ‰é’®æ“ä½œ */
    handleUpdate(row) {
      this.reset();
      const svyid = row.svyid || this.ids
      getSvytitle(svyid).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改问卷";
      });
    },
    /** æäº¤æŒ‰é’® */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.svyid != null) {
            updateSvytitle(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addSvytitle(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** åˆ é™¤æŒ‰é’®æ“ä½œ */
    handleDelete(row) {
      const svyids = row.svyid || this.ids;
      this.$modal.confirm('是否确认删除问卷编号为"' + svyids + '"的数据项?').then(function () {
        return delSvytitle(svyids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.download('smartor/svytitle/export', {
        ...this.queryParams
      }, `svytitle_${new Date().getTime()}.xlsx`)
    },
    handleNodeClick(data) {
      console.log(data);
    },
   },
  components:
  {
    dw_topic: () => import("@/smartor/dataobject/dw_svytopic_view.vue")
  }
};
</script>