123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545 |
- <template>
- <el-dialog
- :title="title"
- :center="true"
- align="left"
- top="5vh"
- width="700px"
- @close="closeModel"
- :close-on-click-modal="false"
- :visible.sync="showModelThis"
- v-loading="loading"
- element-loading-text="拼命加载中"
- element-loading-spinner="el-icon-loading"
- element-loading-background="rgba(0, 0, 0, 0.8)"
- >
- <el-card>
- <el-row :gutter="10">
- <el-col :span="24">
- <el-form
- v-if="isApproval"
- :model="cexForm"
- status-icon
- :rules="cexRules"
- ref="cexForm"
- label-width="80px"
- class="cexForm-ruleForm"
- ><el-row>
- <el-col :span="12">
- <el-row class="cexForm-div">
- <el-col :span="8" class="tr cexForm-label">所属企业:</el-col>
- <el-col :span="16" class="cexForm-main">{{
- dataInfo.company
- }}</el-col>
- </el-row>
- <el-row class="cexForm-div">
- <el-col :span="8" class="tr cexForm-label">账号:</el-col>
- <el-col :span="16" class="cexForm-main">{{
- dataInfo.username
- }}</el-col>
- </el-row>
- <el-row class="cexForm-div">
- <el-col :span="8" class="tr cexForm-label">真实姓名:</el-col>
- <el-col :span="16" class="cexForm-main">{{
- dataInfo.name
- }}</el-col>
- </el-row>
- <el-row class="cexForm-div">
- <el-col :span="8" class="tr cexForm-label">手机号:</el-col>
- <el-col :span="16" class="cexForm-main">{{
- dataInfo.mobile
- }}</el-col>
- </el-row>
- <el-row class="cexForm-div">
- <el-col :span="8" class="tr cexForm-label">邮箱:</el-col>
- <el-col :span="16" class="cexForm-main">{{
- dataInfo.email
- }}</el-col>
- </el-row>
- <el-row class="cexForm-div" v-if="dataInfo.company">
- <el-col :span="8" class="tr cexForm-label">备注:</el-col>
- <el-col :span="16" class="cexForm-main">{{
- dataInfo.remark
- }}</el-col>
- </el-row>
- </el-col>
- <el-col :span="12">
- <el-form-item label="审核状态" prop="status">
- <el-select
- v-model="cexForm.status"
- placeholder="请选择审核状态"
- @change="selectChange"
- >
- <el-option
- v-for="item in statusList"
- :key="item.code"
- :label="item.name"
- :value="item.code"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="审核说明" prop="remark">
- <el-input
- v-model="cexForm.remark"
- type="textarea"
- placeholder="请输入审核说明"
- :rows="5"
- maxlength="300"
- show-word-limit
- ></el-input>
- </el-form-item>
- <el-col :span="24" style="text-align: right">
- <el-button type="primary" @click="submitCexForm"
- >保 存
- </el-button>
- <el-button @click="showModelThis = false">取 消</el-button>
- </el-col>
- </el-col>
- </el-row></el-form
- >
- <el-form
- v-else
- :model="ruleForm"
- status-icon
- :rules="rulesThis"
- ref="ruleForm"
- label-width="80px"
- class="demo-ruleForm"
- ><el-row>
- <el-col :span="24">
- <el-form-item label="所属企业" prop="company_id">
- <el-select
- :disabled="isDetail"
- v-model="ruleForm.company_id"
- filterable
- clearable
- :size="searchSize"
- placeholder="请选择所属企业"
- style="width: 100%"
- >
- <el-option
- v-for="item in companyList"
- :key="'company' + item.id"
- :label="item.company"
- :value="item.id"
- :disabled="item.status === '0'"
- />
- </el-select>
- <!-- <el-input
- v-model="ruleForm.company_id"
- :disabled="isDetail"
- /> -->
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item
- v-if="id === 'add' || isDetail"
- label="账号"
- prop="username"
- >
- <el-input v-model="ruleForm.username" :disabled="isDetail" />
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item label="真实姓名" prop="contact">
- <el-input v-model="ruleForm.contact" :disabled="isDetail" />
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item label="手机号" prop="mobile">
- <el-input v-model="ruleForm.mobile" :disabled="isDetail" />
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item label="邮箱" prop="email">
- <el-input v-model="ruleForm.email" :disabled="isDetail" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item label="信息备注" prop="remark">
- <el-input
- v-model="ruleForm.remark"
- type="textarea"
- placeholder="请输入备注"
- :rows="5"
- maxlength="300"
- show-word-limit
- :disabled="isDetail"
- ></el-input>
- </el-form-item>
- <el-col :span="24" style="text-align: right">
- <el-tag
- type="warning"
- class="fl"
- style="max-width: 500px"
- v-if="dataInfo.ex_remark && dataInfo.ex_status === '2'"
- >审核备注:{{ dataInfo.ex_remark }}</el-tag
- >
- <el-button type="primary" @click="submitForm" v-if="!isDetail"
- >保 存
- </el-button>
- <el-button @click="showModelThis = false">{{
- isDetail ? "关 闭" : "取 消"
- }}</el-button>
- </el-col>
- </el-form>
- </el-col>
- </el-row>
- </el-card>
- </el-dialog>
- </template>
- <script>
- import asyncRequest from "@/apis/service/client/business";
- import {
- isnumber,
- isMobile,
- validEmail,
- isAlphanumeric,
- isChinese,
- isEmoticon,
- validAlphabets,
- } from "@/utils/validate";
- import statusList from "@/assets/js/cexStatusList";
- export default {
- name: "specs",
- props: ["showModel", "id", "isDetail", "isApproval"],
- data() {
- const validateusername = (rule, value, callback) => {
- if (value === "") {
- callback(new Error("账号不能为空!"));
- } else {
- if (value.lenght < 6 || value.lenght > 18) {
- callback(new Error("账号规则为6~18位数字与字母组合!"));
- } else {
- if (isnumber(value)) {
- callback(new Error("账号规则为6~18位数字与字母组合!"));
- } else if (validAlphabets(value)) {
- callback(new Error("账号规则为6~18位数字与字母组合!"));
- } else if (!isAlphanumeric(value)) {
- callback(new Error("账号规则为6~18位数字与字母组合!"));
- } else {
- callback();
- }
- }
- }
- };
- const validatecontact = (rule, value, callback) => {
- if (value === "") {
- callback(new Error("真实姓名不能为空!"));
- } else {
- if (value.lenght < 2 || value.lenght > 12) {
- callback(new Error("真实姓名规则为2~12位汉字!"));
- } else {
- if (!isChinese(value)) {
- callback(new Error("真实姓名为6~18位数字与字母组合!"));
- } else if (isEmoticon(value)) {
- callback(new Error("真实姓名为6~18位数字与字母组合!"));
- } else {
- callback();
- }
- }
- }
- };
- const validatemobile = (rule, value, callback) => {
- if (value === "") {
- callback(new Error("手机号不能为空!"));
- } else {
- if (!isMobile(value)) {
- callback(new Error("手机号格式不正确!"));
- } else {
- callback();
- }
- }
- };
- const validateEmail = (rule, value, callback) => {
- if (value === "") {
- callback(new Error("邮箱不能为空!"));
- } else {
- if (!validEmail(value)) {
- callback(new Error("邮箱格式不正确!"));
- } else {
- callback();
- }
- }
- };
- return {
- statusList: statusList,
- loading: false,
- title: "添加企业客户",
- showModelThis: this.showModel,
- dataInfo: {},
- companyList: [],
- cexForm: {
- id: this.id,
- remark: "",
- status: "1",
- },
- ruleForm: {
- id: this.id, //企业id
- company_id: "", //id
- type: "2",
- username: "", //账号
- contact: "", //真实姓名
- mobile: "", //手机号
- emailz: "", //邮箱
- remark: "",
- },
- cexRules: {
- status: {
- required: true,
- message: "请选择审核状态",
- trigger: "change",
- },
- remark: [
- {
- required: false,
- message: "请输入审核说明!",
- trigger: "blur",
- },
- ],
- },
- rulesThis: this.rules,
- rules: {
- company_id: [
- {
- required: true,
- message: "请选择企业!",
- trigger: "change",
- },
- ],
- username: [
- {
- required: true,
- validator: validateusername,
- trigger: "blur",
- },
- ],
- contact: [
- {
- required: true,
- validator: validatecontact,
- trigger: "blur",
- },
- ],
- mobile: [
- {
- required: true,
- validator: validatemobile,
- trigger: "blur",
- },
- ],
- email: [
- {
- required: true,
- validator: validateEmail,
- trigger: "blur",
- },
- ],
- remark: [
- {
- required: false,
- trigger: "blur",
- },
- ],
- },
- };
- },
- methods: {
- closeModel() {
- console.log("closeModel!!");
- },
- selectChange() {
- if (this.cexForm.status === "1") {
- this.cexRules.remark[0].required = false;
- } else {
- this.cexRules.remark[0].required = true;
- }
- },
- async initForm() {
- if (this.isApproval) {
- this.loading = true;
- this.title = "企业客户审核";
- await this.getCompanyList();
- await this.initData();
- await this.resetcexForm();
- this.selectChange();
- this.loading = false;
- } else {
- this.loading = true;
- await this.getCompanyList();
- if (this.id === "add") {
- this.title = "添加企业客户";
- // this.ruleForm.isAdmin = 0;
- this.rulesThis = this.rules;
- await this.resetForm();
- } else {
- if (this.isDetail) {
- this.title = "企业客户";
- this.rulesThis = {};
- } else {
- this.title = "修改企业客户";
- this.rulesThis = this.rules;
- }
- await this.resetForm();
- await this.initData();
- }
- this.loading = false;
- }
- },
- async resetcexForm() {
- if (this.$refs.cexForm) {
- this.$refs.cexForm.resetFields();
- this.$refs.cexForm.clearValidate();
- this.cexForm = {
- id: this.id,
- remark: "",
- status: "1",
- };
- }
- },
- async initData() {
- this.loading = true;
- let res = await asyncRequest.detail({ id: this.id });
- this.loading = false;
- if (res.code === 0) {
- let data = res.data;
- this.dataInfo = data;
- this.ruleForm = {
- id: this.id, //企业id
- type: "2",
- company_id: data.company_id, //企业id
- username: data.username, //账号
- contact: data.name, //真实姓名
- mobile: data.mobile, //手机号
- email: data.email, //邮箱
- remark: data.remark,
- };
- }
- },
- async resetForm() {
- // 重置
- await this.$nextTick(() => {
- if (this.$refs.ruleForm) {
- this.$refs.ruleForm.resetFields();
- this.$refs.ruleForm.clearValidate();
- this.ruleForm = {
- id: this.id, //企业id
- type: "2",
- company_id: "", //企业id
- username: "", //账号
- contact: "", //联系人
- mobile: "", //手机号
- emailz: "", //邮箱
- remark: "",
- };
- }
- });
- },
- async submitCexForm() {
- await this.$refs.cexForm.validate(async (valid) => {
- if (valid) {
- this.loading = true;
- console.log(this.id);
- console.log(this.cexForm);
- let obj = JSON.parse(JSON.stringify(this.cexForm));
- obj.id = this.id;
- console.log(obj);
- let res = await asyncRequest.exam(obj);
- this.loading = false;
- if (res.code === 0) {
- let title = "审核审批成功!";
- this.$notify.success({
- title,
- message: "",
- });
- this.showModelThis = false;
- // 刷新
- this.$emit("refresh");
- }
- } else {
- console.log("error submit!!");
- return false;
- }
- });
- },
- async submitForm() {
- await this.$refs.ruleForm.validate(async (valid) => {
- if (valid) {
- this.loading = true;
- let obj = JSON.parse(JSON.stringify(this.ruleForm));
- let res = {};
- if (this.id === "add") {
- delete obj["id"];
- res = await asyncRequest.add(obj);
- } else {
- res = await asyncRequest.update(obj);
- }
- this.loading = false;
- if (res.code === 0) {
- let title = this.id === "add" ? "添加成功" : "修改成功";
- this.$notify.success({
- title,
- message: "",
- });
- this.showModelThis = false;
- // 刷新
- this.$emit("refresh");
- }
- } else {
- console.log("error submit!!");
- return false;
- }
- });
- },
- async getCompanyList() {
- let res = await asyncRequest.companyall({ type: "2" });
- if (res.code === 0) {
- this.companyList = res.data;
- }
- },
- },
- watch: {
- showModel: function (val) {
- this.showModelThis = val;
- if (val) {
- this.initForm();
- }
- },
- showModelThis(val) {
- if (!val) {
- this.$emit("cancel");
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .business {
- .cexForm-ruleForm {
- .cexForm-div {
- margin-bottom: 0px;
- .cexForm-label {
- padding-right: 12px;
- color: #606266;
- line-height: 40px;
- font-size: 14px;
- }
- .cexForm-main {
- line-height: 40px;
- color: rgb(151, 168, 190);
- line-height: 40px;
- font-size: 14px;
- }
- }
- }
- }
- </style>
-
|