123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715 |
- <template>
- <div class="m-container">
- <h2>
- <div class="squrt"></div>
- 合作单位
- </h2>
- <div class="m-core">
- <!-- 搜索类型 -->
- <save-form
- :inline="true"
- class="searchForm"
- @submit="search"
- @reset="onReSet"
- :model="searchForm"
- >
- <el-form-item>
- <el-input
- v-model="searchForm.search"
- clearable
- placeholder="请输入合作单位名称"
- ></el-input>
- </el-form-item>
- <el-form-item>
- <el-select
- v-model.trim="searchForm.organId"
- placeholder="请选择分部"
- filterable
- clearable
- >
- <el-option
- v-for="item in selects.branchs"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-select
- v-model.trim="searchForm.isEnable"
- placeholder="请选择状态"
- filterable
- clearable
- >
- <el-option label="开启" :value="true"></el-option>
- <el-option label="关闭" :value="false"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button native-type="submit" type="danger">搜索</el-button>
- <el-button native-type="reset" type="primary">重置</el-button>
- <!-- export/isSettlementCourseSalarys -->
- <el-button
- @click="onExport"
- v-permission="'export/cooperationOrgan'"
- type="primary"
- >导出</el-button
- >
- </el-form-item>
- </save-form>
- <el-button
- @click="openTeaching('create')"
- v-permission="'cooperationOrgan/add'"
- type="primary"
- style="margin-bottom: 20px"
- >
- 新建
- </el-button>
- <!-- 列表 -->
- <div class="tableWrap">
- <el-table
- :data="tableList"
- :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
- >
- <el-table-column align="center" prop="id" label="单位编号">
- </el-table-column>
- <el-table-column align="center" prop="name" label="单位名称">
- </el-table-column>
- <el-table-column align="center" prop="name" label="所属分部">
- <template slot-scope="scope">
- <div>
- {{ scope.row.organization.name }}
- </div>
- </template>
- </el-table-column>
- <el-table-column align="center" prop="realName" label="乐团主管">
- </el-table-column>
- <!-- <el-table-column align="center" prop="linkman" label="联系人">
- </el-table-column>
- <el-table-column align="center" prop="job" label="职位">
- </el-table-column>
- <el-table-column align="center" prop="mobileNo" label="手机号">
- </el-table-column> -->
- <el-table-column align="center" label="是否全职资源">
- <template slot-scope="scope">
- {{ scope.row.fullJobResource ? "是" : "否" }}
- </template>
- </el-table-column>
- <el-table-column align="center" label="状态">
- <template slot-scope="scope">
- <div>
- {{ scope.row.isEnable ? "开启" : "关闭" }}
- </div>
- </template>
- </el-table-column>
- <el-table-column align="center" label="操作" width="140px">
- <template slot-scope="scope">
- <el-button @click="openTeaching('look', scope.row)" type="text"
- >查看</el-button
- >
- <el-button
- @click="openTeaching('update', scope.row)"
- v-permission="'cooperationOrgan/update'"
- type="text"
- >修改</el-button
- >
- <el-button
- @click="onDelete(scope.row)"
- v-permission="'cooperationOrgan/del'"
- type="text"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <pagination
- sync
- :total.sync="pageInfo.total"
- :page.sync="pageInfo.page"
- :limit.sync="pageInfo.limit"
- :page-sizes="pageInfo.page_size"
- @pagination="getList"
- />
- </div>
- </div>
- <el-dialog
- :title="formTitle[formActionTitle]"
- :visible.sync="teachingStatus"
- @close="onFormClose('ruleForm')"
- width="1060px"
- >
- <el-form
- :model="form"
- :rules="rules"
- ref="ruleForm"
- :inline="true"
- class="eidtForm"
- label-position="left"
- >
- <el-alert
- style="margin: 10px 0"
- title="合作单位信息"
- :closable="false"
- type="info"
- >
- </el-alert>
- <el-row>
- <el-form-item
- label="单位名称"
- prop="name"
- :label-width="formLabelWidth"
- >
- <el-input
- v-model.trim="form.name"
- :disabled="basdisabled"
- autocomplete="off"
- ></el-input>
- </el-form-item>
- <el-form-item
- label="所属分部"
- prop="organId"
- :label-width="formLabelWidth"
- >
- <el-select
- :disabled="basdisabled"
- v-model.trim="form.organId"
- @change="changeOrgan"
- filterable
- clearable
- >
- <el-option
- v-for="item in selects.branchs"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-row>
- <el-row>
- <el-form-item
- label="乐团主管"
- prop="educationUserId"
- :label-width="formLabelWidth"
- :rules="[{ required: true, message: '乐团主管不能为空' }]"
- >
- <el-select
- :disabled="!form.organId || basdisabled"
- v-model.trim="form.educationUserId"
- filterable
- clearable
- >
- <el-option
- v-for="item in educationList"
- :key="item.key"
- :label="item.value"
- :value="item.key"
- >
- <span style="float: left">{{ item.value }}</span>
- <span style="float: right; color: #8492a6; font-size: 13px">{{
- String(item.key)
- }}</span>
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- label="合作单位状态"
- prop="isEnable"
- :label-width="formLabelWidth"
- >
- <el-select
- :disabled="basdisabled"
- v-model.trim="form.isEnable"
- filterable
- clearable
- >
- <el-option label="开启" :value="true"></el-option>
- <el-option label="关闭" :value="false"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- label="是否全职资源"
- prop="fullJobResource"
- :label-width="formLabelWidth"
- >
- <el-select
- :disabled="basdisabled"
- v-model.trim="form.fullJobResource"
- >
- <el-option label="是" :value="1"></el-option>
- <el-option label="否" :value="0"></el-option>
- </el-select>
- </el-form-item>
- </el-row>
- <el-alert
- style="margin: 10px 0"
- title="合作单位联系人"
- :closable="false"
- type="info"
- >
- </el-alert>
- <el-row
- v-for="(item, index) in form.cooperationOrganLinkmanList"
- :key="index"
- class="greyRow"
- >
- <div class="concatTitle">
- <p>联系人{{ index + 1 }}</p>
- <i
- class="el-icon-delete-solid marginLeft10 iconStyle"
- v-if="form.cooperationOrganLinkmanList.length > 1 && !basdisabled"
- @click="deleteLinkMan(index)"
- style="font-size: 20px; cursor: pointer"
- ></i>
- </div>
- <el-form-item
- :rules="[
- { required: true, message: '请输入联系人', trigger: 'blur' },
- ]"
- :label="'联系人姓名'"
- :prop="'cooperationOrganLinkmanList.' + index + '.linkman'"
- :label-width="formLabelWidth"
- >
- <el-input
- :disabled="basdisabled"
- v-model.trim="item.linkman"
- autocomplete="off"
- ></el-input>
- </el-form-item>
- <el-form-item
- :rules="[
- { required: true, message: '请输入职位', trigger: 'blur' },
- ]"
- :label="'联系人职位'"
- :prop="'cooperationOrganLinkmanList.' + index + '.job'"
- :label-width="formLabelWidth"
- >
- <el-input
- :disabled="basdisabled"
- v-model.trim="item.job"
- autocomplete="off"
- ></el-input>
- </el-form-item>
- <el-form-item
- :rules="[
- { required: true, validator: validPhone, trigger: 'blur' },
- ,
- {
- pattern: /^1[3456789]\d{9}$/,
- message: '请输入正确的手机号',
- trigger: 'blur',
- },
- ]"
- :label="'联系人手机号'"
- :prop="'cooperationOrganLinkmanList.' + index + '.mobileNo'"
- :label-width="formLabelWidth"
- >
- <el-input
- :disabled="basdisabled"
- v-model.trim="item.mobileNo"
- autocomplete="off"
- ></el-input>
- </el-form-item>
- <!-- <i
- class="el-icon-circle-plus-outline marginLeft10 iconStyle"
- style="font-size: 20px; cursor: pointer"
- ></i> -->
- </el-row>
- <!-- index + 1 == form.cooperationOrganLinkmanList.length -->
- <el-button
- v-if="!basdisabled"
- class="greyRow"
- style="width: 100%"
- icon="el-icon-plus"
- @click="addLinkMan"
- >添加联系人</el-button
- >
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="teachingStatus = false">取 消</el-button>
- <el-button
- type="primary"
- v-if="!basdisabled"
- @click="onTeachingSubmit('ruleForm')"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import pagination from "@/components/Pagination/index";
- import {
- cooperationOrganAdd,
- cooperationOrganUpdate,
- cooperationOrganDel,
- queryPage,
- } from "@/api/systemManage";
- import cleanDeep from "clean-deep";
- import { isvalidPhone } from "@/utils/validate";
- import { Export } from "@/utils/downLoadFile";
- import { getOrganRole } from "@/api/buildTeam";
- import qs from "qs";
- let validPhone = (rule, value, callback) => {
- if (!value) {
- callback(new Error("请输入电话号码"));
- } else if (!isvalidPhone(value)) {
- callback(new Error("请输入正确的11位手机号码"));
- } else {
- callback();
- }
- };
- export default {
- name: "branchManager",
- components: { pagination },
- data() {
- return {
- searchForm: {
- organId: null,
- isEnable: null,
- search: null,
- },
- validPhone,
- searchLsit: [],
- tableList: [],
- educationList: [],
- pageInfo: {
- // 分页规则
- limit: 10, // 限制显示条数
- page: 1, // 当前页
- total: 0, // 总条数
- page_size: [10, 20, 40, 50], // 选择限制显示条数
- },
- teachingStatus: false, // 添加教学点
- formActionTitle: "create",
- formTitle: {
- create: "添加合作单位",
- update: "修改合作单位",
- look: "查看合作单位",
- },
- formLabelWidth: "120px",
- form: {
- id: null,
- name: null, // 教学点名称
- linkman: null, // 来源
- job: null, // 费用
- mobileNo: null,
- fullJobResource: null,
- organId: null,
- educationUserId: null,
- cooperationOrganLinkmanList: [
- { cooperationOrganId: "", job: "", linkman: "", mobileNo: "" },
- ],
- },
- rules: {
- name: [
- { required: true, message: "请输入教学点名称", trigger: "blur" },
- ],
- organId: [
- { required: true, message: "请选择所属分部", trigger: "change" },
- ],
- educationUserId: [
- { required: true, message: "请选择乐团主管", trigger: "change" },
- ],
- fullJobResource: [
- { required: true, message: "请选择是否全职资源", trigger: "change" },
- ],
- isEnable: [
- { required: true, message: "请选择状态", trigger: "change" },
- ],
- },
- basdisabled: false,
- actionRow: null,
- };
- },
- async mounted() {
- this.getList(); // 获取列表数据
- // 获取当前用户分部
- await this.$store.dispatch("setBranchs");
- if (this.selects.branchs.length <= 0) {
- this.$bus.$emit("showguide", ["organ"]);
- }
- },
- methods: {
- onDelete(rows) {
- this.$confirm("您确定删除合作单位?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- cooperationOrganDel(rows.id).then((res) => {
- if (res.code == 200) {
- this.$message.success("删除成功");
- this.teachingStatus = false;
- this.getList();
- } else {
- this.$message.error(res.msg);
- }
- });
- })
- .catch(() => {});
- },
- search() {
- this.pageInfo.page = 1;
- this.getList();
- },
- onReSet() {
- this.searchForm = {
- organId: null,
- isEnable: null,
- };
- this.search();
- },
- onExport() {
- Export(
- this,
- {
- url: "/api-web/export/cooperationOrgan",
- fileName: "合作单位.xls",
- method: "post",
- params: qs.stringify(cleanDeep(this.searchForm)),
- },
- "您确定导出合作单位?"
- );
- },
- onTeachingSubmit(formName) {
- // 添加数据
- this.$refs[formName].validate((valid) => {
- if (valid) {
- if (this.formActionTitle == "create") {
- if (this.form.id) {
- // 判断有没有Id,如果有则删除
- delete this.form.id;
- }
- console.log(this.form);
- cooperationOrganAdd(this.form).then((res) => {
- if (res.code == 200) {
- this.$message.success("创建成功");
- this.teachingStatus = false;
- this.getList();
- } else {
- this.$message.error(res.msg);
- }
- });
- } else if (this.formActionTitle == "update") {
- cooperationOrganUpdate(this.form).then((res) => {
- if (res.code == 200) {
- this.$message.success("修改成功");
- this.teachingStatus = false;
- this.getList();
- } else {
- this.$message.error(res.msg);
- }
- });
- }
- } else {
- return false;
- }
- });
- },
- getList() {
- queryPage({
- rows: this.pageInfo.limit,
- page: this.pageInfo.page,
- ...this.searchForm,
- }).then((res) => {
- if (res.code == 200 && res.data) {
- this.tableList = res.data.rows;
- this.pageInfo.total = res.data.total;
- }
- });
- },
- openTeaching(type, rows) {
- // 重置数据
- this.teachingStatus = true;
- this.formActionTitle = type;
- // 修改的时候赋值
- if (type == "update") {
- this.changeOrgan(rows.organId);
- this.actionRow = rows;
- this.form = {
- id: rows.id,
- name: rows.name, // 教学点名称
- linkman: rows.linkman, // 来源
- job: rows.job, // 费用
- mobileNo: rows.mobileNo ? rows.mobileNo : null,
- ownershipType: rows.ownershipType,
- organId: rows.organId,
- fullJobResource: rows.fullJobResource,
- isEnable: rows.isEnable,
- educationUserId: rows.educationUserId,
- cooperationOrganLinkmanList:
- rows.cooperationOrganLinkmanList.length > 0
- ? rows.cooperationOrganLinkmanList
- : [
- {
- cooperationOrganId: rows.id,
- job: "",
- linkman: "",
- mobileNo: "",
- },
- ],
- };
- this.basdisabled = false;
- } else if (type == "look") {
- this.changeOrgan(rows.organId);
- this.actionRow = rows;
- this.form = {
- id: rows.id,
- name: rows.name, // 教学点名称
- linkman: rows.linkman, // 来源
- job: rows.job, // 费用
- mobileNo: rows.mobileNo ? rows.mobileNo : null,
- ownershipType: rows.ownershipType,
- organId: rows.organId,
- fullJobResource: rows.fullJobResource,
- isEnable: rows.isEnable,
- educationUserId: rows.educationUserId,
- cooperationOrganLinkmanList: rows.cooperationOrganLinkmanList,
- };
- this.basdisabled = true;
- // 查看
- } else {
- this.basdisabled = false;
- this.actionRow = null;
- }
- },
- onFormClose(formName) {
- // 关闭弹窗重置验证
- // this.$refs[formName].clearValidate()
- this.form = {
- id: null,
- name: null, // 教学点名称
- linkman: null, // 来源
- job: null, // 费用
- mobileNo: null,
- fullJobResource: null,
- organId: null,
- isEnable: null,
- educationUserId: null,
- cooperationOrganLinkmanList: [
- { cooperationOrganId: "", job: "", linkman: "", mobileNo: "" },
- ],
- };
- this.$refs[formName].resetFields();
- },
- async changeOrgan(val) {
- this.form.educationUserId = null;
- if (val) {
- try {
- const ruselt = await getOrganRole({
- id: val,
- });
- this.educationList = ruselt?.data?.educationId;
- if (!this.educationList || this.educationList?.length <= 0) {
- this.$bus.$emit("showguide", ["teamManager"]);
- }
- } catch (e) {
- console.log(e);
- }
- }
- },
- deleteLinkMan(index) {
- console.log(this.form.cooperationOrganLinkmanList);
- this.form.cooperationOrganLinkmanList.splice(index, 1);
- },
- addLinkMan() {
- if (this.actionRow) {
- // 修改
- console.log(this.actionRow);
- this.form.cooperationOrganLinkmanList.push({
- cooperationOrganId: this.actionRow.id,
- job: "",
- linkman: "",
- mobileNo: "",
- });
- } else {
- // 新增
- this.form.cooperationOrganLinkmanList.push({
- cooperationOrganId: "",
- job: "",
- linkman: "",
- mobileNo: "",
- });
- }
- },
- },
- watch: {
- teachingStatus(val) {
- if (!val) {
- this.getList();
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .eidtForm {
- /deep/.el-form-item__content {
- display: block !important;
- }
- // /deep/.el-form--inline {
- // }
- /deep/.el-select {
- width: 300px !important;
- }
- /deep/.el-date-editor {
- width: 300px !important;
- }
- /deep/.el-checkbox {
- margin-left: 15px !important;
- }
- /deep/.el-input {
- position: relative;
- font-size: 14px;
- display: inline-block;
- width: 300px !important;
- }
- }
- .greyRow {
- background-color: #f9f9f9;
- padding: 10px;
- margin-bottom: 10px;
- }
- /deep/.el-select {
- width: 100% !important;
- }
- .el-vue-search-box-container {
- position: absolute !important;
- left: 10px;
- margin-top: 10px;
- z-index: 99999 !important;
- }
- .iconStyle {
- color: #999;
- line-height: 40px;
- }
- .marginLeft10 {
- margin-left: 10px;
- }
- .concatTitle {
- line-height: 36px;
- font-size: 14px;
- font-weight: bold;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- }
- </style>
|