branchManager.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. 合作单位
  6. </h2>
  7. <div class="m-core" v-if="tableList.length>0 || pageInfo.page>1">
  8. <!-- 搜索类型 -->
  9. <save-form
  10. :inline="true"
  11. class="searchForm"
  12. @submit="search"
  13. @reset="onReSet"
  14. :model="searchForm"
  15. >
  16. <el-form-item>
  17. <el-input
  18. v-model="searchForm.search"
  19. clearable
  20. placeholder="请输入合作单位名称"
  21. ></el-input>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-select
  25. v-model.trim="searchForm.organId"
  26. placeholder="请选择分部"
  27. filterable
  28. clearable
  29. >
  30. <el-option
  31. v-for="item in selects.branchs"
  32. :key="item.id"
  33. :label="item.name"
  34. :value="item.id"
  35. ></el-option>
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item>
  39. <el-select
  40. v-model.trim="searchForm.isEnable"
  41. placeholder="请选择状态"
  42. filterable
  43. clearable
  44. >
  45. <el-option label="开启" :value="true"></el-option>
  46. <el-option label="关闭" :value="false"></el-option>
  47. </el-select>
  48. </el-form-item>
  49. <el-form-item>
  50. <el-button native-type="submit" type="danger">搜索</el-button>
  51. <el-button native-type="reset" type="primary">重置</el-button>
  52. <!-- export/isSettlementCourseSalarys -->
  53. <el-button
  54. @click="onExport"
  55. v-permission="'export/cooperationOrgan'"
  56. type="primary"
  57. >导出</el-button
  58. >
  59. </el-form-item>
  60. </save-form>
  61. <el-button
  62. @click="openTeaching('create')"
  63. v-permission="'cooperationOrgan/add'"
  64. type="primary"
  65. style="margin-bottom: 20px"
  66. >
  67. 新建
  68. </el-button>
  69. <!-- 列表 -->
  70. <div class="tableWrap">
  71. <el-table
  72. :data="tableList"
  73. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  74. >
  75. <el-table-column align="center" prop="id" label="单位编号">
  76. </el-table-column>
  77. <el-table-column align="center" prop="name" label="单位名称">
  78. </el-table-column>
  79. <el-table-column align="center" prop="name" label="所属分部">
  80. <template slot-scope="scope">
  81. <div>
  82. {{ scope.row.organization.name }}
  83. </div>
  84. </template>
  85. </el-table-column>
  86. <el-table-column align="center" prop="realName" label="乐团主管">
  87. </el-table-column>
  88. <!-- <el-table-column align="center" prop="linkman" label="联系人">
  89. </el-table-column>
  90. <el-table-column align="center" prop="job" label="职位">
  91. </el-table-column>
  92. <el-table-column align="center" prop="mobileNo" label="手机号">
  93. </el-table-column> -->
  94. <el-table-column
  95. align="center"
  96. label="是否全职资源"
  97. v-if="tenantId == 1"
  98. >
  99. <template slot-scope="scope">
  100. {{ scope.row.fullJobResource ? "是" : "否" }}
  101. </template>
  102. </el-table-column>
  103. <el-table-column align="center" label="状态">
  104. <template slot-scope="scope">
  105. <div>
  106. {{ scope.row.isEnable ? "开启" : "关闭" }}
  107. </div>
  108. </template>
  109. </el-table-column>
  110. <el-table-column align="center" label="操作" width="140px">
  111. <template slot-scope="scope">
  112. <el-button @click="openTeaching('look', scope.row)" type="text"
  113. >查看</el-button
  114. >
  115. <el-button
  116. @click="openTeaching('update', scope.row)"
  117. v-permission="'cooperationOrgan/update'"
  118. type="text"
  119. >修改</el-button
  120. >
  121. <el-button
  122. @click="onDelete(scope.row)"
  123. v-permission="'cooperationOrgan/del'"
  124. type="text"
  125. >删除</el-button
  126. >
  127. </template>
  128. </el-table-column>
  129. </el-table>
  130. <pagination
  131. sync
  132. :total.sync="pageInfo.total"
  133. :page.sync="pageInfo.page"
  134. :limit.sync="pageInfo.limit"
  135. :page-sizes="pageInfo.page_size"
  136. @pagination="getList"
  137. />
  138. </div>
  139. </div>
  140. <emptyPage @submit="openTeaching('create')" title='合作单位' btnTitle='新建合作单位' :context='context' v-else />
  141. <el-dialog
  142. :title="formTitle[formActionTitle]"
  143. :visible.sync="teachingStatus"
  144. width="1060px"
  145. >
  146. <el-form
  147. :model="form"
  148. :rules="rules"
  149. ref="ruleForm"
  150. :inline="true"
  151. class="eidtForm"
  152. label-position="left"
  153. >
  154. <el-alert
  155. style="margin: 10px 0"
  156. title="合作单位信息"
  157. :closable="false"
  158. type="info"
  159. >
  160. </el-alert>
  161. <el-row>
  162. <el-form-item
  163. label="单位名称"
  164. prop="name"
  165. :label-width="formLabelWidth"
  166. >
  167. <el-input
  168. v-model.trim="form.name"
  169. :disabled="basdisabled"
  170. autocomplete="off"
  171. ></el-input>
  172. </el-form-item>
  173. <el-form-item
  174. label="所属分部"
  175. prop="organId"
  176. :label-width="formLabelWidth"
  177. >
  178. <el-select
  179. :disabled="basdisabled"
  180. v-model.trim="form.organId"
  181. @change="changeOrgan"
  182. filterable
  183. clearable
  184. >
  185. <el-option
  186. v-for="item in selects.branchs"
  187. :key="item.id"
  188. :label="item.name"
  189. :value="item.id"
  190. ></el-option>
  191. </el-select>
  192. </el-form-item>
  193. </el-row>
  194. <el-row>
  195. <el-form-item
  196. label="乐团主管"
  197. prop="educationUserId"
  198. :label-width="formLabelWidth"
  199. :rules="[{ required: true, message: '乐团主管不能为空' }]"
  200. >
  201. <el-select
  202. :disabled="!form.organId || basdisabled"
  203. v-model.trim="form.educationUserId"
  204. filterable
  205. clearable
  206. >
  207. <el-option
  208. v-for="(item, key) in educationList"
  209. :key="key"
  210. :label="item.userName"
  211. :value="item.userId"
  212. >
  213. <span style="float: left">{{ item.userName }}</span>
  214. <span style="float: right; color: #8492a6; font-size: 13px">{{
  215. String(item.userId)
  216. }}</span>
  217. </el-option>
  218. </el-select>
  219. </el-form-item>
  220. <el-form-item
  221. label="合作单位状态"
  222. prop="isEnable"
  223. :label-width="formLabelWidth"
  224. >
  225. <el-select
  226. :disabled="basdisabled"
  227. v-model.trim="form.isEnable"
  228. filterable
  229. clearable
  230. >
  231. <el-option label="开启" :value="true"></el-option>
  232. <el-option label="关闭" :value="false"></el-option>
  233. </el-select>
  234. </el-form-item>
  235. <el-form-item
  236. v-if="tenantId == 1"
  237. label="是否全职资源"
  238. prop="fullJobResource"
  239. :label-width="formLabelWidth"
  240. >
  241. <el-select
  242. :disabled="basdisabled"
  243. v-model.trim="form.fullJobResource"
  244. >
  245. <el-option label="是" :value="1"></el-option>
  246. <el-option label="否" :value="0"></el-option>
  247. </el-select>
  248. </el-form-item>
  249. </el-row>
  250. <el-alert
  251. style="margin: 10px 0"
  252. title="合作单位联系人"
  253. :closable="false"
  254. type="info"
  255. >
  256. </el-alert>
  257. <el-row
  258. v-for="(item, index) in form.cooperationOrganLinkmanList"
  259. :key="index"
  260. class="greyRow"
  261. >
  262. <div class="concatTitle">
  263. <p>联系人{{ index + 1 }}</p>
  264. <i
  265. class="el-icon-delete-solid marginLeft10 iconStyle"
  266. v-if="form.cooperationOrganLinkmanList.length > 1 && !basdisabled"
  267. @click="deleteLinkMan(index)"
  268. style="font-size: 20px; cursor: pointer"
  269. ></i>
  270. </div>
  271. <el-form-item
  272. :rules="[
  273. { required: true, message: '请输入联系人', trigger: 'blur' },
  274. ]"
  275. :label="'联系人姓名'"
  276. :prop="'cooperationOrganLinkmanList.' + index + '.linkman'"
  277. :label-width="formLabelWidth"
  278. >
  279. <el-input
  280. :disabled="basdisabled"
  281. v-model.trim="item.linkman"
  282. autocomplete="off"
  283. ></el-input>
  284. </el-form-item>
  285. <el-form-item
  286. :rules="[
  287. { required: true, message: '请输入职位', trigger: 'blur' },
  288. ]"
  289. :label="'联系人职位'"
  290. :prop="'cooperationOrganLinkmanList.' + index + '.job'"
  291. :label-width="formLabelWidth"
  292. >
  293. <el-input
  294. :disabled="basdisabled"
  295. v-model.trim="item.job"
  296. autocomplete="off"
  297. ></el-input>
  298. </el-form-item>
  299. <el-form-item
  300. :rules="[
  301. { required: true, validator: validPhone, trigger: 'blur' },
  302. ,
  303. {
  304. pattern: /^1[3456789]\d{9}$/,
  305. message: '请输入正确的手机号',
  306. trigger: 'blur',
  307. },
  308. ]"
  309. :label="'联系人手机号'"
  310. :prop="'cooperationOrganLinkmanList.' + index + '.mobileNo'"
  311. :label-width="formLabelWidth"
  312. >
  313. <el-input
  314. :disabled="basdisabled"
  315. :max="11"
  316. :min="11"
  317. maxlength="11"
  318. v-model.trim="item.mobileNo"
  319. autocomplete="off"
  320. ></el-input>
  321. </el-form-item>
  322. <!-- <i
  323. class="el-icon-circle-plus-outline marginLeft10 iconStyle"
  324. style="font-size: 20px; cursor: pointer"
  325. ></i> -->
  326. </el-row>
  327. <!-- index + 1 == form.cooperationOrganLinkmanList.length -->
  328. <el-button
  329. v-if="!basdisabled"
  330. class="greyRow"
  331. style="width: 100%"
  332. icon="el-icon-plus"
  333. @click="addLinkMan"
  334. >添加联系人</el-button
  335. >
  336. </el-form>
  337. <span slot="footer" class="dialog-footer">
  338. <el-button @click="teachingStatus = false">取 消</el-button>
  339. <el-button
  340. type="primary"
  341. v-if="!basdisabled"
  342. @click="onTeachingSubmit('ruleForm')"
  343. >确 定</el-button
  344. >
  345. </span>
  346. </el-dialog>
  347. </div>
  348. </template>
  349. <script>
  350. import pagination from "@/components/Pagination/index";
  351. import {
  352. cooperationOrganAdd,
  353. cooperationOrganUpdate,
  354. cooperationOrganDel,
  355. queryPage,
  356. } from "@/api/systemManage";
  357. import cleanDeep from "clean-deep";
  358. import { isvalidPhone } from "@/utils/validate";
  359. import { Export } from "@/utils/downLoadFile";
  360. import { getOrganRole } from "@/api/buildTeam";
  361. import emptyPage from '@/components/emptyPage'
  362. import qs from "qs";
  363. let validPhone = (rule, value, callback) => {
  364. if (!value) {
  365. callback(new Error("请输入电话号码"));
  366. } else if (!isvalidPhone(value)) {
  367. callback(new Error("请输入正确的11位手机号码"));
  368. } else {
  369. callback();
  370. }
  371. };
  372. export default {
  373. name: "branchManager",
  374. components: { pagination,emptyPage },
  375. data() {
  376. return {
  377. searchForm: {
  378. organId: null,
  379. isEnable: null,
  380. search: null,
  381. },
  382. validPhone,
  383. searchLsit: [],
  384. tableList: [],
  385. educationList: [],
  386. pageInfo: {
  387. // 分页规则
  388. limit: 10, // 限制显示条数
  389. page: 1, // 当前页
  390. total: 0, // 总条数
  391. page_size: [10, 20, 40, 50], // 选择限制显示条数
  392. },
  393. teachingStatus: false, // 添加教学点
  394. formActionTitle: "create",
  395. formTitle: {
  396. create: "添加合作单位",
  397. update: "修改合作单位",
  398. look: "查看合作单位",
  399. },
  400. formLabelWidth: "120px",
  401. form: {
  402. id: null,
  403. name: null, // 教学点名称
  404. linkman: null, // 来源
  405. job: null, // 费用
  406. mobileNo: null,
  407. fullJobResource: null,
  408. organId: null,
  409. educationUserId: null,
  410. cooperationOrganLinkmanList: [
  411. { cooperationOrganId: "", job: "", linkman: "", mobileNo: "" },
  412. ],
  413. },
  414. rules: {
  415. name: [
  416. { required: true, message: "请输入教学点名称", trigger: "blur" },
  417. ],
  418. organId: [
  419. { required: true, message: "请选择所属分部", trigger: "change" },
  420. ],
  421. educationUserId: [
  422. { required: true, message: "请选择乐团主管", trigger: "change" },
  423. ],
  424. fullJobResource: [
  425. { required: true, message: "请选择是否全职资源", trigger: "change" },
  426. ],
  427. isEnable: [
  428. { required: true, message: "请选择状态", trigger: "change" },
  429. ],
  430. },
  431. basdisabled: false,
  432. actionRow: null,
  433. tenantId: null,
  434. context:'合作单位即为合作学校,可以为本机构下的各个分部创建合作单位,创建乐团时需选择合作单位用于区分和管理各合作方的乐团。若本机构乐团无合作方,可将本机构创建为合作单位,并在创建乐团时选择。'
  435. };
  436. },
  437. async mounted() {
  438. this.tenantId = this.$helpers.tenantId;
  439. this.getList(); // 获取列表数据
  440. // 获取当前用户分部
  441. await this.$store.dispatch("setBranchs");
  442. if (this.selects.branchs.length <= 0) {
  443. this.$bus.$emit("showguide", ["organ"]);
  444. }
  445. },
  446. methods: {
  447. onDelete(rows) {
  448. this.$confirm("您确定删除合作单位?", "提示", {
  449. confirmButtonText: "确定",
  450. cancelButtonText: "取消",
  451. type: "warning",
  452. })
  453. .then(() => {
  454. cooperationOrganDel(rows.id).then((res) => {
  455. if (res.code == 200) {
  456. this.$message.success("删除成功");
  457. this.teachingStatus = false;
  458. this.getList();
  459. } else {
  460. this.$message.error(res.msg);
  461. }
  462. });
  463. })
  464. .catch(() => {});
  465. },
  466. search() {
  467. this.pageInfo.page = 1;
  468. this.getList();
  469. },
  470. onReSet() {
  471. this.searchForm = {
  472. organId: null,
  473. isEnable: null,
  474. };
  475. this.search();
  476. },
  477. onExport() {
  478. Export(
  479. this,
  480. {
  481. url: "/api-web/export/cooperationOrgan",
  482. fileName: "合作单位.xls",
  483. method: "post",
  484. params: qs.stringify(cleanDeep(this.searchForm)),
  485. },
  486. "您确定导出合作单位?"
  487. );
  488. },
  489. onTeachingSubmit(formName) {
  490. // 添加数据
  491. this.$refs[formName].validate((valid) => {
  492. if (valid) {
  493. if (this.formActionTitle == "create") {
  494. if (this.form.id) {
  495. // 判断有没有Id,如果有则删除
  496. delete this.form.id;
  497. }
  498. cooperationOrganAdd(this.form).then((res) => {
  499. if (res.code == 200) {
  500. this.$message.success("创建成功");
  501. this.teachingStatus = false;
  502. this.getList();
  503. } else {
  504. this.$message.error(res.msg);
  505. }
  506. });
  507. } else if (this.formActionTitle == "update") {
  508. cooperationOrganUpdate(this.form).then((res) => {
  509. if (res.code == 200) {
  510. this.$message.success("修改成功");
  511. this.teachingStatus = false;
  512. this.getList();
  513. } else {
  514. this.$message.error(res.msg);
  515. }
  516. });
  517. }
  518. } else {
  519. return false;
  520. }
  521. });
  522. },
  523. getList() {
  524. queryPage({
  525. rows: this.pageInfo.limit,
  526. page: this.pageInfo.page,
  527. ...this.searchForm,
  528. }).then((res) => {
  529. if (res.code == 200 && res.data) {
  530. this.tableList = res.data.rows;
  531. this.pageInfo.total = res.data.total;
  532. }
  533. });
  534. },
  535. openTeaching(type, rows) {
  536. // 重置数据
  537. this.teachingStatus = true;
  538. this.actionRow = { ...rows } || null;
  539. this.formActionTitle = type;
  540. // 修改的时候赋值
  541. if (type == "update") {
  542. this.changeOrgan(rows.organId);
  543. this.form = {
  544. id: rows.id,
  545. name: rows.name, // 教学点名称
  546. linkman: rows.linkman, // 来源
  547. job: rows.job, // 费用
  548. mobileNo: rows.mobileNo ? rows.mobileNo : null,
  549. ownershipType: rows.ownershipType,
  550. organId: rows.organId,
  551. fullJobResource: rows.fullJobResource,
  552. isEnable: rows.isEnable,
  553. educationUserId: rows.educationUserId,
  554. };
  555. let cooperationOrganLinkmanList =
  556. rows.cooperationOrganLinkmanList.length > 0
  557. ? [...rows.cooperationOrganLinkmanList]
  558. : [
  559. {
  560. cooperationOrganId: rows.id,
  561. job: "",
  562. linkman: "",
  563. mobileNo: "",
  564. },
  565. ];
  566. this.$set(
  567. this.form,
  568. "cooperationOrganLinkmanList",
  569. cooperationOrganLinkmanList
  570. );
  571. this.basdisabled = false;
  572. } else if (type == "look") {
  573. this.changeOrgan(rows.organId);
  574. this.form = {
  575. id: rows.id,
  576. name: rows.name, // 教学点名称
  577. linkman: rows.linkman, // 来源
  578. job: rows.job, // 费用
  579. mobileNo: rows.mobileNo ? rows.mobileNo : null,
  580. ownershipType: rows.ownershipType,
  581. organId: rows.organId,
  582. fullJobResource: rows.fullJobResource,
  583. isEnable: rows.isEnable,
  584. educationUserId: rows.educationUserId,
  585. };
  586. let cooperationOrganLinkmanList = rows.cooperationOrganLinkmanList.length>0?[...rows.cooperationOrganLinkmanList]:[];
  587. this.$set(
  588. this.form,
  589. "cooperationOrganLinkmanList",
  590. cooperationOrganLinkmanList
  591. );
  592. this.basdisabled = true;
  593. // 查看
  594. } else {
  595. this.basdisabled = false;
  596. this.actionRow = null;
  597. }
  598. },
  599. async changeOrgan(val) {
  600. this.form.educationUserId = null;
  601. if (val) {
  602. try {
  603. const ruselt = await getOrganRole({
  604. id: val,
  605. });
  606. this.educationList = ruselt?.data?.EDUCATION;
  607. if (!this.educationList || this.educationList?.length <= 0) {
  608. this.$bus.$emit("showguide", ["teamManager"]);
  609. }
  610. } catch (e) {
  611. console.log(e);
  612. }
  613. }
  614. },
  615. deleteLinkMan(index) {
  616. this.form.cooperationOrganLinkmanList.splice(index, 1);
  617. },
  618. addLinkMan() {
  619. if (this.actionRow) {
  620. // 修改
  621. this.form.cooperationOrganLinkmanList.push({
  622. cooperationOrganId: this.actionRow.id,
  623. job: "",
  624. linkman: "",
  625. mobileNo: "",
  626. });
  627. } else {
  628. // 新增
  629. this.form.cooperationOrganLinkmanList.push({
  630. cooperationOrganId: "",
  631. job: "",
  632. linkman: "",
  633. mobileNo: "",
  634. });
  635. }
  636. },
  637. },
  638. watch: {
  639. teachingStatus(val) {
  640. if (!val) {
  641. this.form = {
  642. id: null,
  643. name: null, // 教学点名称
  644. linkman: null, // 来源
  645. job: null, // 费用
  646. mobileNo: null,
  647. fullJobResource: null,
  648. organId: null,
  649. isEnable: null,
  650. educationUserId: null,
  651. cooperationOrganLinkmanList: [],
  652. };
  653. this.$refs.ruleForm.resetFields();
  654. }
  655. },
  656. },
  657. };
  658. </script>
  659. <style lang="scss" scoped>
  660. .eidtForm {
  661. /deep/.el-form-item__content {
  662. display: block !important;
  663. }
  664. // /deep/.el-form--inline {
  665. // }
  666. /deep/.el-select {
  667. width: 300px !important;
  668. }
  669. /deep/.el-date-editor {
  670. width: 300px !important;
  671. }
  672. /deep/.el-checkbox {
  673. margin-left: 15px !important;
  674. }
  675. /deep/.el-input {
  676. position: relative;
  677. font-size: 14px;
  678. display: inline-block;
  679. width: 300px !important;
  680. }
  681. }
  682. .greyRow {
  683. background-color: #f9f9f9;
  684. padding: 10px;
  685. margin-bottom: 10px;
  686. }
  687. /deep/.el-select {
  688. width: 100% !important;
  689. }
  690. .el-vue-search-box-container {
  691. position: absolute !important;
  692. left: 10px;
  693. margin-top: 10px;
  694. z-index: 99999 !important;
  695. }
  696. .iconStyle {
  697. color: #999;
  698. line-height: 40px;
  699. }
  700. .marginLeft10 {
  701. margin-left: 10px;
  702. }
  703. .concatTitle {
  704. line-height: 36px;
  705. font-size: 14px;
  706. font-weight: bold;
  707. display: flex;
  708. flex-direction: row;
  709. justify-content: space-between;
  710. }
  711. </style>