Blame view

antis-ncc-admin/src/views/extend/zyZbwfConsult/SubForm.vue 2.99 KB
03207d5d   wwk   1
1
2
3
4
5
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
  <template>
    <el-dialog title="添加项目进度信息" :close-on-click-modal="false" :visible.sync="visible"
      class="NCC-dialog NCC-dialog_center" lock-scroll width="600px">
      <el-input v-model="text" placeholder="输入具体内容" type="textarea" :rows="3" />
      <el-timeline class="timeline">
        <el-timeline-item  v-for="(item, index) in activities" :key="index" type="primary">
          <div class="el-timeline-content">
            <p class="text">{{item.text}}</p>
            <p class="time">
              <span>{{item.userId}} 提交于 {{item.creatorTime}}</span>
              <span class="del" @click="handleDel(index)">
                <i class="el-icon-delete"></i>删除
              </span>
            </p>
          </div>
        </el-timeline-item>
      </el-timeline>
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{$t('common.cancelButton')}}</el-button>
        <el-button type="primary" @click="dataFormSubmit()">提 交</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { getPostil, zyZbConsultDeletePostil, sendPostil } from '@/api/extend/zyZbConsult'
  export default {
    data() {
      return {
        visible: false,
        id: 0,
        text: '',
        activities: []
      }
    },
    methods: {
      init(id) {
        this.id = id || 0
        this.visible = true
        this.$nextTick(() => {
          if (this.id) this.getList()
        })
      },
      getList() {
        getPostil(this.id).then(res => {
  						this.activities = res.data.postilJson ? JSON.parse(res.data.postilJson) : []
  				})
      },
      handleDel(index) {
        this.$confirm(this.$t('common.delTip'), this.$t('common.tipTitle'), {
          type: 'warning'
        }).then(() => {
          zyZbConsultDeletePostil(this.id, index).then(res => {
  					 this.activities.splice(index, 1);
             this.$message({ type: 'success', message: res.msg });
             this.$emit('refreshDatalist')
  				})
        }).catch(() => { });
      },
      dataFormSubmit() {
        if (!this.text) {
          this.$message({ message: '项目进度内容不能为空', type: 'error', duration: 1000 })
          return
        }
        sendPostil(this.id, { text: this.text }).then(res => {
  					  this.$message({
              message: res.msg,
              type: 'success',
              duration: 1500,
              onClose: () => {
                 this.getList()
                 this.text = ''
                 this.$emit('refreshDatalist')
               }
            })
  			})
      }
    }
  }
  </script>
  <style lang="scss" scoped>
  .timeline {
    padding-top: 30px;
  }
  >>> .el-timeline-content {
    p {
      padding: 0;
      margin: 0;
    }
    .text {
      line-height: 25px;
      margin-bottom: 10px;
      color: #475059;
      font-size: 14px;
      font-weight: bold;
    }
    .time {
      font-size: 12px;
      display: flex;
      justify-content: space-between;
      opacity: 0.4;
      .del {
        display: none;
        color: rgb(255, 91, 91);
        cursor: pointer;
        i {
          margin-right: 5px;
        }
      }
    }
    &:hover {
      .del {
        display: block;
      }
    }
  }
  </style>