rk
2025-09-22 cf2391a86bdea88196d49cd33949570f74c0985d
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
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
<template>
  <GlobalAlertWindow
    :title="title"
    :visible.sync="visible"
    :confirm-working="isWorking"
    @confirm="confirm"
    width="500px"
  >
    <el-form :model="form" ref="form" :rules="rules" label-width="100px">
      <!-- {{ roleType }} -->
      <el-form-item label="角色名称" prop="roleType">
        <el-select :disabled="isEdit" v-model="form.roleType" placeholder="请选择角色">
          <el-option
            v-for="item in roleType"
            :key="item.value"
            :value="item.value"
            :label="item.name"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="评价权重(%)"  prop="rate">
        <!-- @input="inputZAction(form, 'ratio')" -->
        <el-input v-model="form.rate" @input="numInput(form, 'rate')" placeholder="请输入评价权重(0-100)" v-trim/>
      </el-form-item>
      <el-form-item label="评价方式" prop="type">
        <el-select v-model="form.type" placeholder="请选择评价方式">
          <el-option
            v-for="item in type"
            :key="item.value"
            :value="item.value"
            :label="item.name"
          ></el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="评价方式" prop="type">
        <el-select v-model="form.type" placeholder="请选择评价方式">
          <el-option
            v-for="item in type"
            :key="item.id"
            :value="item.id"
            :label="item.name"
          ></el-option>
        </el-select>
      </el-form-item> -->
    </el-form>
  </GlobalAlertWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalAlertWindow from '@/components/common/GlobalAlertWindow'
export default {
  name: 'OperaProjectRoleSorceWindow',
  extends: BaseOpera,
  components: { GlobalAlertWindow },
  data () {
    return {
      // 表单数据
      form: {
        id: null,
        roleType: '',
        rate: '',
        projectId: '',
        type: 1
      },
      type: [
        { name: '线上', value: 0 },
        { name: '线下', value: 1 },
      ],
      roleType: [],
      isEdit: false,
      // 验证规则
      rules: {
        name: [
          { required: true, message: '请输入类型名称', trigger: 'blur' }
        ]
      }
    }
  },
  // inject: ['roleType'],
  created () {
    this.config({
      api: '/business/projectScore',
      'field.id': 'id'
    })
  },
 
  methods: {
    open (title, target, projectId, roleType) {
      this.title = title
      this.visible = true
      // debugger
      this.form.projectId = projectId
      this.roleType = roleType
      this.isEdit = true
      // 新建
      if (target == null) {
        this.isEdit = false
        this.$nextTick(() => {
          this.$refs.form.resetFields()
          this.form[this.configData['field.id']] = null
        })
        
        return
      }
      // 编辑
      this.$nextTick(() => {
        for (const key in this.form) {
          this.form[key] = target[key]
        }
       
      })
    },
    inputZAction(item, key) {
      // item[key] = item[key].replace(/[0], '')
      // item[key]=item[key].replace(/0|[^\d]+/g, '')
      if (item[key]>=1) {
        item[key] = 1
        return
      }
      item[key] = item[key].replace(/[^\d.]/g, '') //清楚数字和.以外的字符
                      .replace(/\.{2,}/g, '.')
                      .replace('.', '$#$')
                      .replace(/\./g, '')
                      .replace('$#$', '.')
                      .replace(/^(\-)*(\d+)\.(\d).*$/, '$1$2.$3')
                      .replace(/^\./g, '')
    },
    numInput(item, key) {
      // =""
      if (item[key] < 0) {
        item[key] = ''
      }
      item[key]=item[key].replace(/[^\d]+/g, '')
      console.log(item[key]);
    },
  }
}
/**
 * 
 
 */
</script>
 
<style lang="scss" scoped>
@import "@/assets/style/alertstyle.scss";
</style>