Blame view

src/views/workflow/components/dialog/commonOpinion.vue 4.53 KB
1 2 3 4 5
<!--
 * @Description: 
 * @Autor: renchao
 * @LastEditTime: 2023-05-17 10:40:02
-->
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
<template>
  <div>
    <el-button type="primary" native-type="submit" @click="openDialog">新增常用</el-button>
    <el-form ref="form" :model="form" :rules="rules" label-width="80px" v-show="addDialog">
      <el-form-item prop="commonOpinion">
        <div class="invalid-reson">常用意见:</div>
        <el-input v-model="form.commonOpinion" placeholder="请输入常用意见" type="textarea" :rows="4"></el-input>
      </el-form-item>
      <el-form-item class="text-center">
        <el-button @click="closeaddDiglog">取 消</el-button>
        <el-button type="primary" @click="addOpinion">确 定</el-button>
      </el-form-item>
    </el-form>
    <lb-table :heightNumSetting="true"
      @row-dblclick="handleRowClick"
      :pagination="false" :column="columns" :minHeight="300" :data="tableData.data">
    </lb-table>
    <div style="height:15px"></div>
    <div class="text-center">
      <el-button @click="$popupCacel">取消</el-button>
    </div>
  </div>
</template>
<script>
  import store from '@/store/index.js'
  import { getUserCommonOpinion, addUserCommonOpinion, delUserCommonOpinion } from "@/api/fqsq.js"
  export default {
    components: {},
    props: {
      formData: {
        type: Object,
        default: {}
      }
    },
    data () {
      return {
        addDialog: false,
        columns: [
          {
            label: '序号',
            type: 'index',
            width: '50',
          },
          {
            prop: "opinion",
            label: "意见描述",
          },
          {
            label: '操作',
            width: '100',
            render: (h, scope) => {
              return (
                <div>
                  <el-button type="text" onClick={() => { this.useCommonOpinion(scope.row) }}>使用</el-button>
                  <el-button type="text" onClick={() => { this.deleteOpinion(scope.row) }}>删除</el-button>
                </div>
              )
            }
          }
        ],
        tableData: {
          total: 0,
          data: [],
        },
        form: {
          commonOpinion: '',
        },
        rules: {
          commonOpinion: [
            { required: true, message: '请输入常用意见', trigger: 'blur' }
          ]
        }
      }
    },
    mounted () {
      this.getList()
    },
    methods: {
      getList () {
        getUserCommonOpinion().then(res => {
          this.tableData.data = res.result
        })
      },
      //新增常用意见
      addOpinion () {
        this.$refs.form.validate(valid => {
          if (valid) {
            addUserCommonOpinion({ commonOpinion: this.form.commonOpinion }).then(res => {
              if (res.code == 200) {
                this.$message.success("新增成功")
                this.closeaddDiglog();
                this.getList()
              } else {
                this.$message.error(res.message)
              }
            })
          } else {
            return false;
          }
        });
      },
      //打开新增弹窗
      openDialog () {
        this.addDialog = true
      },
      //关闭新增弹窗
      closeaddDiglog () {
        this.addDialog = false
        this.$refs['form'].resetFields();
      },
      handleRowClick (item) {
        this.useCommonOpinion(item)
      },
      //使用常用意见
      useCommonOpinion (item) {
        store.dispatch('workflow/setOptions', item.opinion);
        this.$popupCacel()
      },
      //删除常用意见
      deleteOpinion (item) {
        this.$confirm("确定要删除吗, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          delUserCommonOpinion({ bsmOpinion: item.bsmOpinion }).then(res => {
            if (res.code == 200) {
              this.$message.success("删除成功")
              this.getList()
            } else {
              this.$message.error(res.message)
            }
          })
        })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消删除",
            });
          });
      },
      //关闭列表弹窗
      closeDialog () {
        this.form.commonOpinion = "";
      }
    }
  }
</script>
<style scoped lang='scss'>
  @import "~@/styles/mixin.scss";
  @import "~@/styles/dialogBox.scss";

  .invalid-reson {
    margin-bottom: 10px;
  }

  .dialog-footer {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
  }
</style>