hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<template>
  <div class="box-card">
    <div class="details-center">
      <h3 class="fz-10 fw-bold mr-b-10" style="padding-top: 20px">
        {{ info_id ? "编辑" : "新增" }}项目
      </h3>
      <el-form
        :model="paramData"
        :rules="paramRules"
        ref="paramForm"
        label-width="250px"
      >
        <div>
          <div class="fl-fw">
            <el-form-item label="职能特长及服务意愿">
              <el-select
                filterable
                multiple
                collapse-tags
                class="iw-220"
                v-model="specialtyNameValue"
                placeholder="请选择职能特长及服务意愿"
              >
                <el-option
                  v-for="item in skillList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.label"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </div>
          <el-form-item label="服务项目名称">
            <el-input
              class="iw-220"
              clearable
              placeholder="请输入服务项目名称"
              v-model.trim="paramData.title"
            ></el-input>
          </el-form-item>
          <el-form-item label="项目图片">
            <UploadImg
              :imgNum="1"
              formKey="imgUrl"
              :imgShow="paramData.imgUrl"
              @fileHandle="uploadHandleHealth"
            />
          </el-form-item>
          <el-form-item label="项目负责人电话" prop="phone">
            <el-input
              class="iw-220"
              clearable
              maxlength="11"
              placeholder="请输入项目负责人电话"
              v-model.trim="paramData.phone"
            ></el-input>
          </el-form-item>
        </div>
 
        <el-form-item prop="password" label="">
          <el-button @click="handleAction('close')">取 消</el-button>
          <el-button
            type="primary"
            :loading="btnType"
            @click="handleAction('submit')"
            >提 交</el-button
          >
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import { objCopyPro } from "../../../utils/common";
import { PHONE } from "@/utils/validation";
import UploadImg from "../../../components/upload/uploadImg.vue";
export default {
  components: {
    UploadImg
  },
  data() {
    return {
      info_id: "",
      btnType: false,
      communityId: "",
      paramData: {
        phone: "",
        meritId: "",
        title: "",
        imgUrl: ""
      },
      paramRules: {
        meritId: [
          {
            required: true,
            message: "请选择职能特长及服务意愿",
            trigger: "change"
          }
        ],
        title: [{ required: true, message: "请输入项目名称", trigger: "blur" }],
        phone: [{ required: true, validator: PHONE, trigger: "blur" }]
      }, // 表单验证
      cityChooseList: [],
      propsCityTourst: {
        label: "value",
        value: "value"
      },
      communityListValue: [],
      villageList: [],
      specialtyNameValue: [],
      skillList: [
        { label: "党建指导", value: 1, checkType: false },
        { label: "政策宣讲", value: 2, checkType: false },
        { label: "教育培训", value: 3, checkType: false },
        { label: "就业服务", value: 4, checkType: false },
        { label: "志愿服务", value: 5, checkType: false },
        { label: "维修服务", value: 6, checkType: false },
        { label: "家政服务", value: 7, checkType: false },
        { label: "其他", value: 8, checkType: false }
      ],
      skillOtherType: false
    };
  },
  mounted() {
    this.info_id = this.$route.query.id;
    this.unitId = this.$route.query.unitId;
    this.communityId = this.$route.query.communityId;
    if (this.info_id) {
      this.getDataInfo();
    }
    //
  },
  methods: {
    getDataInfo() {
      //   this.$api.get("/comAreaTownCommunity/areaTownCommunityNew", {}, (res) => {
      //     this.areaChooseList = res;
      //   });
      this.$api.get(
        `StriveFor/ResourceSharing/getResourceSharingDetails`,
        { id: this.info_id },
        res => {
          const BACK_DATA_INFO = res;
          this.paramData = objCopyPro(this.paramData, BACK_DATA_INFO);
          this.specialtyNameValue = res.meritId ? res.meritId.split(",") : [];
          this.skillOtherType = this.specialtyNameValue.some(item => {
            return item === "其他";
          });
        }
      );
    },
    // 页面操作
    async handleAction(type, row) {
      switch (type) {
        case "close": {
          this.$router.back();
          break;
        }
        case "submit": {
          this.$refs.paramForm.validate(val => {
            if (val) {
              //   this.btnType = true;
              this.paramData.meritId = this.specialtyNameValue.join(",");
              this.paramData.unitId = this.unitId;
              this.paramData.communityId = this.communityId;
              if (this.info_id) {
                this.paramData.id = this.info_id;
 
                this.$api.post(
                  "StriveFor/ResourceSharing/editResourceSharingData",
                  this.paramData,
                  () => {
                    // this.btnType = false;
                    demo.toast("编辑成功");
                    this.$router.back();
                  }
                );
              } else {
                this.$api.post(
                  "StriveFor/ResourceSharing/addResourceSharingData",
                  this.paramData,
                  () => {
                    // this.btnType = false;
                    demo.toast("提交成功");
                    this.$router.back();
                  }
                );
              }
            }
          });
          break;
        }
        default: {
          break;
        }
      }
    },
    skillChange(arr) {
      this.skillOtherType = arr.some(item => {
        return item === "其他";
      });
      console.log(arr);
      this.paramData.meritId = arr.join(",");
    },
    uploadHandleHealth({ type, val, key }) {
      if (type === "loading") {
        this.btnType = val;
      } else {
        this.paramData[key] = val;
        this.$refs.paramForm.validateField(key);
      }
    }
  }
};
</script>
<style scoped>
.textarea-width {
  width: 400px;
}
.iw-220 {
  width: 250rpx !important;
}
.iw-200 {
  width: 200rpx !important;
}
 
.addBtn {
  margin-left: 20px;
}
</style>