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
<template>
  <GlobalAlertWindow
    :title="title"
    :visible.sync="visible"
    :confirm-working="isWorking"
    @confirm="confirm"
  >
    <div class="tips-style">已经服务完成的报名信息关联的子账号不会修改</div>
    <el-form :model="form" ref="form" :rules="rules">
      <el-form-item label="用户名称" prop="sdUserId">
        <el-select v-model="form.sdUserId" placeholder="请选择用户">
          <el-option
            v-for="item in sd"
            :key="item.id"
            :value="item.id"
            :label="item.username"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="服务机构" prop="soId">
        <el-select v-model="form.soId" filterable placeholder="请选择服务机构">
          <el-option
            v-for="item in so"
            :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'
import { fetchList as childList } from '@/api/business/childrenUser'
import { list } from '@/api/business/company'
import { distributionChildAccount } from '@/api/business/declares'
export default {
  name: 'ComprehenDistributionChild',
  extends: BaseOpera,
  components: { GlobalAlertWindow },
  data () {
    return {
      // 表单数据
      form: {
        projectId: '',
        sdUserId: '',
        soId: '' // 服务机构id
      },
      sd: [],
      so: [],
      // 验证规则
      rules: {
      }
    }
  },
  created () {
    this.config({
      api: '/business/account',
      'field.id': 'id'
    })
    
  },
  methods: {
    open(title, target) {
      this.title = title
      this.visible = true
      this.$nextTick(() => {
        for (const key in this.form) {
          this.form[key] = target[key]
        }
        this.initData()
      })
    },
    initData() {
      childList({
        capacity: 9999,
        model: {}
      })
        .then(res => {
          this.sd = res.records
        })
        .catch(e => {
          this.$message.error(e)
        })
      list({ type: '1', projectId: this.form.projectId })
        .then(res => {
          this.so = res
        })
        .catch(e => {
          this.$message.error(e)
        })
      
    },
    confirm() {
      this.$refs.form.validate((valid) => {
        if (!valid) {
          return
        }
        // 调用新建接口
        this.isWorking = true
        distributionChildAccount(this.form)
          .then(() => {
            this.visible = false
            this.$message.success('分配成功')
            this.$emit('success')
          })
          .catch(e => {
            this.$message.error(e)
          })
          .finally(() => {
            this.isWorking = false
          })
      })
    }
  },
}
</script>
 
<style lang="scss" scoped>
@import "@/assets/style/alertstyle.scss";
.tips-style {
  height: 44px;
  line-height: 44px;
  // background: rgba(33,110,238,0.1);
  background: rgba(238,56,33,0.06);
  border-radius: 2px;
  padding: 0 20px;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  // color: #216EEE;
  color: #EE3821;
  margin-bottom: 10px;
}
::v-deep .el-select {
  width: 100%;
  .el-input__inner {
    width: 100%;
  }
}
</style>