| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416 |
- <!--
- * @Description: 新增/编辑弹框
- * @Author: Sugar.
- * @Date: 2023-11-24 13:55:00
- * @LastEditors: gcz
- * @LastEditTime: 2024-04-22 16:57:27
- * @FilePath: \great_webui\src\views\distribution\personnelMr\dialog\addAndEdit.vue
- * @Copyright: Copyright (c) 2016~2023 by Sugar., All Rights Reserved.
- -->
- <template>
- <el-dialog
- :title="title"
- :visible.sync="open"
- width="700px"
- append-to-body
- :close-on-click-modal="false"
- @close="cancel"
- >
- <div class="dialog">
- <el-form :model="form" ref="form" :rules="rules" label-width="120px">
- <el-form-item label="分销商名称:" prop="name">
- <el-input
- v-model="form.name"
- placeholder="分销商名称"
- clearable
- style="width: 100%;"
- />
- </el-form-item>
- <el-form-item label="分销商类型:" prop="type">
- <el-select
- v-model="form.type"
- placeholder="分销商类型"
- clearable
- style="width: 100%;"
- >
- <el-option
- v-for="dict in dict.type.distribution_type"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="分销商标签:" prop="personsType">
- <el-select
- v-model="form.personsType"
- placeholder="分销商标签"
- clearable
- style="width: 100%;"
- >
- <el-option
- v-for="dict in dict.type.persons_type"
- :key="dict.value"
- :label="dict.label"
- :value="Number(dict.value)"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="负责人:" prop="contact">
- <el-input
- v-model="form.contact"
- placeholder="负责人"
- clearable
- style="width: 100%;"
- />
- <span style="font-size: 12px;color: #777;">注:负责人姓名必须与微信实名信息一致</span>
- </el-form-item>
- <el-form-item label="岗位" prop="postLabel">
- <el-input v-model="form.postLabel" placeholder="请输入岗位"></el-input>
- </el-form-item>
- <el-form-item label="销售人员:" prop="salePerson">
- <el-input
- v-model="form.salePerson"
- placeholder="销售人员"
- clearable
- style="width: 100%;"
- />
- </el-form-item>
- <!-- <el-form-item label="上级分销人员:" prop="parentId">
- <el-select
- v-model="form.parentId"
- filterable
- remote
- clearable
- reserve-keyword
- placeholder="请选择上级分销人员"
- :remote-method="remoteMethod"
- :loading="parentNameLoading">
- <el-option
- v-for="item in parentNameList"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- </el-form-item> -->
- <el-form-item label="是否可提现:" prop="allowWithdraw">
- <el-radio-group v-model="form.allowWithdraw">
- <el-radio v-for="dict in dict.type.user_allow_withdraw"
- :key="dict.value"
- :label="Number(dict.value)"
- >{{ dict.label }}</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="账号/联系电话:" prop="mobile">
- <el-input
- v-model="form.mobile"
- placeholder="联系电话"
- clearable
- style="width: 100%;"
- />
- </el-form-item>
- <el-form-item label="密码:">
- <el-input
- show-password
- v-model="form.password"
- placeholder="密码"
- autocomplete="new-password"
- clearable
- style="width: 100%;"
- />
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="cancel">取消</el-button>
- <el-button
- type="primary"
- @click="submitForm"
- v-loading.fullscreen.lock="loading"
- element-loading-text="提交中..."
- element-loading-spinner="el-icon-loading"
- element-loading-background="rgba(0, 0, 0, 0.8)"
- >
- <span v-if="loading">提交中...</span>
- <span v-else>保存</span>
- </el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- // import { updateNoticeMgr } from "@/api/system/noticeMgr";
- import { saveAndEdit, getSelectById,pageList } from "@/api/distribution/personnelMr";
- import Editor from "@/components/Editor";
- import { getToken } from "@/utils/auth";
- export default {
- name: "addAndEdit",
- dicts:['user_allow_withdraw','distribution_type','persons_type'],
- components: {
- Editor,
- },
- data() {
- return {
- title: "编辑",
- model: "EDIT",
- activeName: '01',
- open: false,
- loading: false,
- form: {
- id: undefined,
- },
- rules: {
- name: [{ required: true, message: "请输入分销商名称", trigger: ["change","blur"] }],
- type: [{ required: true, message: "请选择分销商类型", trigger: ["change","blur"] }],
- personsType: [{ required: true, message: "请选择分销商标签", trigger: ["change","blur"] }],
- contact: [{ required: true, message: "请输入负责人", trigger: ["change","blur"] }],
- mobile: [{ required: true, message: "请输入账号/联系电话", trigger: ["change","blur"] }],
- allowWithdraw: [{ required: true, message: "请选择是否可提现", trigger: ["change","blur"] }],
- //parentId: [{ required: true, message: "请选择上级分销人员", trigger: ["change","blur"] }],
- salePerson: [{ required: true, message: "请输入销售人员名称", trigger: ["change","blur"] }],
- postLabel: [{ required: false, message: "请输入岗位", trigger: ["change","blur"] }],
- },
- uploadObj: {
- url: process.env.VUE_APP_UPLOAD_FILE_API + "/upload/single/minio",
- Headers: { Authorization: "Bearer " + getToken() },
- },
- parentNameLoading: false,
- parentNameList: [],
- parentId: null,
- };
- },
- methods: {
- /**
- * 打开弹框
- * @date 2023-11-22
- * @param {any} obj
- * @returns {any}
- */
- openDialog(title, obj) {
- this.open = true;
- this.parentId = null
- this.reset();
- this.parentNameList = []
- if (obj){
- this.title = "编辑分销人员";
- this.getSelectByIdApi(obj);
- }else{
- this.title = "添加分销人员";
- this.$nextTick(() => {
- this.$refs["form"].clearValidate();
- });
- }
- },
- /** 获取详情 */
- getSelectByIdApi(row) {
- const id = row.id
- getSelectById(id).then(response => {
- const obj = response.data;
- this.parentId = obj.id
- if(row.parentId && obj.parentId != 0){
- this.getList({id:row.parentId})
- }
- this.$nextTick(() => {
- this.$set(this.form, 'id', obj.id);
- this.$set(this.form, 'name', obj.name);
- this.$set(this.form, 'type', obj.type + '');
- this.$set(this.form, 'contact', obj.contact);
- this.$set(this.form, 'mobile', obj.mobile);
- this.$set(this.form, 'allowWithdraw', obj.allowWithdraw);
- this.$set(this.form, 'parentName', obj.parentName);
- this.$set(this.form, 'parentId', obj.parentId && obj.parentId != 0 ? obj.parentId : null);
- this.$set(this.form, 'salePerson', obj.salePerson);
- this.$set(this.form, 'postLabel', obj.postLabel);
- this.$set(this.form, 'personsType', obj.personsType);
- });
- });
-
- },
- /**
- * 保存
- * @date 2023-11-22
- * @returns {any}
- */
- submitForm() {
- this.$refs["form"].validate(async (valid) => {
- if (valid) {
- try {
- this.loading = true;
- const { code } = await saveAndEdit({
- ...this.form,
- parentId: this.form.parentId && this.form.parentId != 0 ? this.form.parentId : 0
- });
- if (code === 200) {
- this.$message.success("操作成功!");
- this.$emit("getList");
- this.cancel();
- }
- } catch (error) {
- } finally {
- this.loading = false;
- }
- }
- });
- },
- /**
- * 重置
- * @date 2023-11-22
- * @returns {any}
- */
- reset() {
- this.$set(this.form, 'id', '');
- this.$set(this.form, 'name', '');
- this.$set(this.form, 'type', '');
- this.$set(this.form, 'contact', '');
- this.$set(this.form, 'mobile', '');
- this.$set(this.form, 'password', '');
- this.$set(this.form, 'parentId', '');
- this.$set(this.form, 'salePerson', '');
- this.$set(this.form, 'postLabel', '');
- this.$set(this.form, 'personsType', '');
- },
- /**
- * 关闭弹框
- * @date 2023-11-22
- * @returns {any}
- */
- cancel() {
- this.reset();
- this.open = false;
- },
- /**
- * 上传成功
- * @date 2023-11-22
- * @param {any} res
- * @returns {any}
- */
- handleAvatarSuccess(res) {
- if (res.code === 200) {
- // this.form.mainImg = res?.data?.url;
- this.$set(this.form, 'mainImg', res?.data?.url)
- }
- },
- /**
- * 上传文件之前之前
- * @date 2023-11-22
- * @param {any} file
- * @returns {any}
- */
- beforeAvatarUpload(file) {
- const isJPG = file.type === "image/jpeg" || "image/png";
- if (!isJPG) {
- this.$message.error("上传头像图片只能是jpg或png格式!");
- }
- return isJPG;
- },
- /**
- * 剧目海报上传成功
- * @date 2023-11-22
- * @param {any} res
- * @returns {any}
- */
- handlePhotoListSuccess(res) {
- if (res.code === 200) {
- let photo = {
- imageUrl: res?.data?.url,
- url: res?.data?.url,
- photoType: '2'
- }
- if(!this.form.photoList){
- this.form.photoList = []
- }
- // this.form.photoList.push(photo);
- this.$set(this.form.photoList, this.form.photoList.length, photo);
- }
- },
- handleRemove(file, fileList) {
- this.form.photoList.forEach((item, index) => {
- if(item.uid == file.uid){
- this.form.photoList.splice(index, 1)
- }
- })
- },
- remoteMethod(query) {
- if (query !== '') {
- this.parentNameLoading = true;
- pageList({
- name: query
- })
- .then(response => {
- this.parentNameLoading = false;
- let list = []
- console.log("list===",this.parentId)
- response.data.rows.forEach((item,index)=>{
- if(this.parentId != item.id) {
- list.push(item)
- }
- })
- this.parentNameList = [].concat(list);
- this.parentNameLoading = false;
- }
- ).catch ((error)=>{
- console.error('error===',error)
- this.parentNameLoading = false;
- })
- } else {
- this.parentNameList = [];
- }
- },
- getList(query) {
- if (query !== '') {
- this.parentNameLoading = true;
- pageList({
- ...query
- })
- .then(response => {
- this.parentNameLoading = false;
- let list = []
- response.data.rows.forEach((item,index)=>{
- if(this.parentId != item.id) {
- list.push(item)
- }
- })
- this.parentNameList = [].concat(list);
- this.parentNameLoading = false;
- }
- ).catch ((error)=>{
- console.error('error===',error)
- this.parentNameLoading = false;
- })
- } else {
- this.parentNameList = [];
- }
- }
- },
- };
- </script>
- <style lang="scss" scoped>
- .dialog {
- padding: 0 30px;
- max-height: 65vh;
- overflow-y: auto;
- }
- .dialog {
- padding: 0 30px;
- .upload-btn {
- width: 100px;
- height: 100px;
- background-color: #fbfdff;
- border: dashed 1px #c0ccda;
- border-radius: 5px;
- i {
- font-size: 30px;
- margin-top: 20px;
- }
- &-text {
- margin-top: -10px;
- }
- }
- .avatar {
- cursor: pointer;
- }
- }
- </style>
|