branchManager.vue 19 KB

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