branchManager.vue 20 KB

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