branchManager.vue 22 KB

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