gaoluyang
4 小时以前 e449a5408265e4bd1f6c66f5be28a42efac444ee
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
148
<!--
  项目团队子表的一行
 
  成员 / 角色下拉由父级统一拉取后传入(多个行共用一份选项,不重复请求)。
  提交时后端不反查 userName / userRoleName,所以选中后要把 label 一起记在 row 上。
-->
<template>
  <view class="team-card">
    <view class="team-header">
      <text class="team-title">成员 {{ index + 1 }}</text>
      <up-icon name="trash"
               color="#ee0a24"
               size="18"
               @click="$emit('remove')"></up-icon>
    </view>
    <up-divider></up-divider>
 
    <view class="team-body">
      <view class="field-row">
        <text class="field-label">姓名</text>
        <FormPicker v-model="row.memberId"
                    type="select"
                    title="选择项目成员"
                    :options="userOptions"
                    placeholder="请选择成员"
                    @change="onMemberChange" />
      </view>
 
      <view class="field-row">
        <text class="field-label">项目组角色</text>
        <FormPicker v-model="row.roleId"
                    type="select"
                    title="选择项目组角色"
                    :options="roleOptions"
                    placeholder="请选择角色"
                    @change="onRoleChange" />
      </view>
 
      <view class="field-row">
        <text class="field-label">进入日期</text>
        <FormPicker v-model="row.enterDate"
                    type="date"
                    placeholder="请选择进入日期" />
      </view>
 
      <view class="field-row">
        <text class="field-label">离开日期</text>
        <FormPicker v-model="row.leaveDate"
                    type="date"
                    placeholder="请选择离开日期" />
      </view>
 
      <view class="field-row">
        <text class="field-label">联系方式</text>
        <u-input v-model="row.phone"
                 placeholder="请输入联系方式"
                 border="none"
                 inputAlign="right" />
      </view>
 
      <view class="field-row">
        <text class="field-label">备注</text>
        <u-input v-model="row.remark"
                 placeholder="请输入备注"
                 border="none"
                 inputAlign="right" />
      </view>
    </view>
  </view>
</template>
 
<script setup>
  import FormPicker from "@/components/FormPicker.vue";
 
  const props = defineProps({
    row: {
      type: Object,
      required: true,
    },
    index: {
      type: Number,
      default: 0,
    },
    userOptions: {
      type: Array,
      default: () => [],
    },
    roleOptions: {
      type: Array,
      default: () => [],
    },
  });
 
  defineEmits(["remove"]);
 
  // 选中后把 label 记到行上,提交时随 payload 一起发给后端
  const onMemberChange = (value, item) => {
    props.row.memberName = item?.name || props.row.memberName || "";
  };
 
  const onRoleChange = (value, item) => {
    props.row.roleName = item?.name || props.row.roleName || "";
  };
</script>
 
<style scoped lang="scss">
  .team-card {
    background: #fff;
    border-radius: 12px;
    padding: 0 12px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  }
 
  .team-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
  }
 
  .team-title {
    font-size: 14px;
    font-weight: 600;
    color: #22324d;
  }
 
  .team-body {
    padding-top: 4px;
  }
 
  .field-row {
    display: flex;
    align-items: center;
    min-height: 44px;
    border-bottom: 1px solid #f5f6fa;
  }
 
  .field-row:last-child {
    border-bottom: none;
  }
 
  .field-label {
    width: 96px;
    flex-shrink: 0;
    font-size: 14px;
    color: #606266;
  }
</style>