| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- <style lang="scss">
- .preview {
- .el-form-item {
- margin-bottom: 15px;
- }
- label,
- p {
- line-height: 25px !important;
- }
- }
- </style>
- <template>
- <section>
- <p><span>信息管理></span>问卷模板</p>
- <div class="content">
- <div class="filter">
- <el-form
- size="small"
- label-width="70px"
- :inline="true"
- label-position="left"
- >
- <el-form-item label="">
- <el-input
- clearable
- placeholder="请输入您要搜索的内容"
- v-model="form.name"
- @clear="search"
- @keyup.enter.native="search"
- ></el-input>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="search">搜索</el-button>
- </el-form-item>
- <el-form-item style="float: right">
- <el-button
- @click="(dialogVisible = true), (dialogTitle = '新增模板'),form1={}"
- type="primary"
- >新增模板</el-button
- >
- </el-form-item>
- </el-form>
- </div>
- <el-table
- class="table"
- :data="list"
- height="50vh"
- border
- v-loading="loading"
- default-expand-all
- row-key="id"
- style="width: 100%"
- >
- <el-table-column prop="name" label="模板名称"> </el-table-column>
- <el-table-column prop="cname" label="创建人"> </el-table-column>
- <el-table-column prop="ctime" label="创建时间"> </el-table-column>
- <el-table-column prop="zip" width="250" label="操作">
- <template slot-scope="scope">
- <el-button
- class="edit"
- type="text"
- @click="edit(scope.row)"
- v-if="scope.row.edit"
- >编辑</el-button
- >
- <el-tooltip
- v-else
- class="item"
- effect="dark"
- content="该模版使用的问卷正在被填报,无法修改,可新增模版-选择复用历史模版使用该模版或删除正在使用该模版的问卷!"
- placement="top-start"
- >
- <el-button
- class="edit"
- type="text"
- style="color: #ccc; cursor: not-allowed"
- >编辑</el-button
- >
- </el-tooltip>
- <el-button
- class="del"
- @click="del(scope.row.id)"
- type="text"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <Page
- ref="pageButton"
- :current="form.page"
- :page_size="form.page_size"
- :total="total"
- @pageChange="gopage"
- />
- </div>
- <el-dialog
- :title="dialogTitle"
- :close-on-click-modal="false"
- :visible.sync="dialogVisible"
- >
- <el-form
- ref="form1"
- size="small"
- class="preview"
- :inline="false"
- label-width="100px"
- :rules="rules"
- :model="form1"
- >
- <el-form-item label="复用历史模板" v-if="!form1.id">
- <el-select
- v-model="form1.copyid"
- filterable
- @change="changeTemplate"
- placeholder="请选择历史模板"
- >
- <el-option
- v-for="(item, index) in allTemplate"
- :key="index"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="模板名称" prop="name">
- <el-input
- v-model="form1.name"
- placeholder="请输入模板名称"
- maxlength="50"
- show-word-limit
- ></el-input>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button size="small" type="primary" @click="addTtitle"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- </section>
- </template>
- <script>
- import Page from "../../components/Page";
- export default {
- components: {
- Page,
- },
- data() {
- return {
- // edit:0,
- allTemplate: [],
- form: { name: "", page: 1, page_size: 20 },
- form1: {name:""},
- total: 1,
- list: [{ name: "2333" }],
- loading: false,
- input: "",
- dialogVisible: false,
- dialogTitle: "",
- defaultProps: {},
- data: [],
- rules: {
- name: [{ required: true, message: "请输入标题", trigger: "blur" }],
- },
- };
- },
- methods: {
- switchStatus(row) {
- this.$api.editTemplateStatus({id:row.id}).then((res)=>{
- row.status = res.data.data
- })
- },
- changeTemplate(val) {
- let selVal = this.allTemplate.filter(function (x) {
- return x.id == val;
- });
- this.form1.name = selVal[0].name;
- // this.form1.name = "111"
- },
- addTtitle() {
- this.$refs["form1"].validate((valid) => {
- if (valid) {
- let query = { title: this.form1.name, id: this.form1.id };
- if (this.form1.copyid) {
- query.id = this.form1.copyid;
- query.copyid = this.form1.copyid;
- }
- this.$router.push({
- path: "/message/template/add",
- query: query,
- });
- }
- });
- },
- search() {
- let parm = this.form;
- this.getData();
- },
- getData() {
- var parm = this.form;
- this.loading = true;
- this.$api.getTemplateList(parm).then((res) => {
- this.list = res.data.data.list;
- this.total = res.data.data.total;
- this.loading = false;
- });
- this.$api.getAllTemplateList().then((res) => {
- this.allTemplate = res.data.data;
- });
- },
- edit(row) {
- this.$api.getTemplate({ id: row.id }).then((res) => {
- // this.form1 = row;
- this.form1 = res.data.data;
- this.dialogVisible = true;
- });
- },
- del(id) {
- this.$confirm(
- "删除模板与模板相关联的消息会被一起删除,确定删除吗?",
- "提示",
- {
- type: "warning",
- }
- ).then(() => {
- this.$api.delTemplate({ id: id }).then((res) => {
- this.$message({
- message: "删除成功",
- type: "success",
- });
- this.getData();
- });
- });
- },
- gopage(size) {
- if (size) {
- this.form.page_size = size;
- }
- this.form.page = this.$refs.pageButton.page;
- this.getData();
- },
- },
- created() {
- this.getData();
- },
- };
- </script>
|