|
|
@@ -0,0 +1,189 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-button size="mini" :type="btnType || 'text'" @click="show">{{ $t("编 辑") }}</el-button>
|
|
|
+ <el-drawer
|
|
|
+ :title="$t('编辑服务人员')"
|
|
|
+ :visible.sync="dialogFormVisible"
|
|
|
+ direction="rtl"
|
|
|
+ append-to-body
|
|
|
+ :show-close="false"
|
|
|
+ size="664px"
|
|
|
+ @close="onCancel"
|
|
|
+ >
|
|
|
+ <div class="drawer__panel">
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-form
|
|
|
+ :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ ref="form"
|
|
|
+ :label-width="tool.onlyZh('90px')"
|
|
|
+ label-position="right"
|
|
|
+ size="mini"
|
|
|
+ >
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('手机号')" prop="phonenumber">
|
|
|
+ <el-input v-model="form.phonenumber" :placeholder="$t('请输入手机号')" maxlength="11" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('登录密码')" prop="password" :rules="passwordType === 'new' ? rules.password : []">
|
|
|
+ <el-radio-group v-model="passwordType" style="margin-bottom: 8px">
|
|
|
+ <el-radio label="keep">{{ $t("原密码") }}</el-radio>
|
|
|
+ <el-radio label="new">{{ $t("新密码") }}</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ <el-input
|
|
|
+ v-if="passwordType === 'new'"
|
|
|
+ v-model="form.password"
|
|
|
+ :placeholder="$t('请输入新密码')"
|
|
|
+ show-password
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('姓名')" prop="name">
|
|
|
+ <el-input v-model="form.name" :placeholder="$t('请输入姓名')" maxlength="50" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('性别')" prop="sex">
|
|
|
+ <el-radio-group v-model="form.sex">
|
|
|
+ <el-radio label="男">{{ $t("男") }}</el-radio>
|
|
|
+ <el-radio label="女">{{ $t("女") }}</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('职位')" prop="position">
|
|
|
+ <el-input v-model="form.position" :placeholder="$t('请输入职位')" maxlength="50" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item :label="$t('备注')" prop="remarks">
|
|
|
+ <el-input
|
|
|
+ type="textarea"
|
|
|
+ v-model="form.remarks"
|
|
|
+ :placeholder="$t('请输入备注')"
|
|
|
+ maxlength="200"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-form>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ <div class="fixed__btn__panel">
|
|
|
+ <el-button size="small" class="normal-btn-width" @click="onCancel">{{ $t("取 消") }}</el-button>
|
|
|
+ <el-button size="small" class="normal-btn-width" type="warning" :loading="loading" @click="onSubmit">{{ $t("保 存") }}</el-button>
|
|
|
+ </div>
|
|
|
+ </el-drawer>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import md5 from "js-md5";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "edit",
|
|
|
+ props: {
|
|
|
+ data: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({}),
|
|
|
+ },
|
|
|
+ btnType: {
|
|
|
+ type: String,
|
|
|
+ default: "text",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ dialogFormVisible: false,
|
|
|
+ loading: false,
|
|
|
+ passwordType: "keep",
|
|
|
+ form: {
|
|
|
+ phonenumber: "",
|
|
|
+ password: "",
|
|
|
+ name: "",
|
|
|
+ sex: "",
|
|
|
+ position: "",
|
|
|
+ remarks: "",
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ phonenumber: [
|
|
|
+ { required: true, message: this.$t("请输入手机号"), trigger: "blur" },
|
|
|
+ {
|
|
|
+ pattern: /^1[3-9]\d{9}$/,
|
|
|
+ message: this.$t("请输入正确的手机号"),
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ name: [
|
|
|
+ { required: true, message: this.$t("请输入姓名"), trigger: "blur" },
|
|
|
+ ],
|
|
|
+ password: [
|
|
|
+ { required: true, message: this.$t("请输入新密码"), trigger: "blur" },
|
|
|
+ { min: 6, max: 20, message: this.$t("密码长度在6到20位之间"), trigger: "blur" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ passwordType(val) {
|
|
|
+ if (val === "keep") {
|
|
|
+ this.form.password = "";
|
|
|
+ this.$refs.form.clearValidate("password");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ show() {
|
|
|
+ this.passwordType = "keep";
|
|
|
+ this.form = {
|
|
|
+ phonenumber: this.data.phonenumber || "",
|
|
|
+ password: "",
|
|
|
+ name: this.data.name || "",
|
|
|
+ sex: this.data.sex || "",
|
|
|
+ position: this.data.position || "",
|
|
|
+ remarks: this.data.remarks || "",
|
|
|
+ };
|
|
|
+ this.dialogFormVisible = true;
|
|
|
+ },
|
|
|
+ onCancel() {
|
|
|
+ this.dialogFormVisible = false;
|
|
|
+ this.$refs.form.resetFields();
|
|
|
+ },
|
|
|
+ onSubmit() {
|
|
|
+ this.$refs.form.validate(async (valid) => {
|
|
|
+ if (!valid) return;
|
|
|
+
|
|
|
+ this.loading = true;
|
|
|
+ const content = {
|
|
|
+ sa_agents_service_hrid: this.data.sa_agents_service_hrid,
|
|
|
+ name: this.form.name,
|
|
|
+ phonenumber: this.form.phonenumber,
|
|
|
+ position: this.form.position,
|
|
|
+ sex: this.form.sex,
|
|
|
+ remarks: this.form.remarks,
|
|
|
+ };
|
|
|
+
|
|
|
+ if (this.passwordType === "keep") {
|
|
|
+ content.password = this.data.password;
|
|
|
+ } else if (this.form.password) {
|
|
|
+ content.password = md5(this.form.password);
|
|
|
+ }
|
|
|
+
|
|
|
+ const res = await this.$api.requested({
|
|
|
+ id: 2026051913192002,
|
|
|
+ content,
|
|
|
+ });
|
|
|
+
|
|
|
+ this.tool.showMessage(res, () => {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.loading = false;
|
|
|
+ this.dialogFormVisible = false;
|
|
|
+ this.$emit("onSuccess");
|
|
|
+ }, 500);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|