branchManager.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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. <div
  62. @click="openTeaching('create')"
  63. v-permission="'cooperationOrgan/add'"
  64. class="newBand"
  65. >
  66. 新建
  67. </div>
  68. <!-- 列表 -->
  69. <div class="tableWrap">
  70. <el-table
  71. :data="tableList"
  72. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  73. >
  74. <el-table-column align="center" prop="id" label="单位编号">
  75. </el-table-column>
  76. <el-table-column align="center" prop="name" label="单位名称">
  77. </el-table-column>
  78. <el-table-column align="center" prop="name" label="所属分部">
  79. <template slot-scope="scope">
  80. <div>
  81. {{ scope.row.organization.name }}
  82. </div>
  83. </template>
  84. </el-table-column>
  85. <el-table-column align="center" prop="realName" label="乐团主管">
  86. </el-table-column>
  87. <el-table-column align="center" prop="linkman" label="联系人">
  88. </el-table-column>
  89. <el-table-column align="center" prop="job" label="职位">
  90. </el-table-column>
  91. <el-table-column align="center" prop="mobileNo" label="手机号">
  92. </el-table-column>
  93. <el-table-column align="center" label="是否全职资源">
  94. <template slot-scope="scope">
  95. {{ scope.row.fullJobResource ? "是" : "否" }}
  96. </template>
  97. </el-table-column>
  98. <el-table-column align="center" label="状态">
  99. <template slot-scope="scope">
  100. <div>
  101. {{ scope.row.isEnable ? "开启" : "关闭" }}
  102. </div>
  103. </template>
  104. </el-table-column>
  105. <el-table-column align="center" label="操作" width="100">
  106. <template slot-scope="scope">
  107. <el-button
  108. @click="openTeaching('update', scope.row)"
  109. v-permission="'cooperationOrgan/update'"
  110. type="text"
  111. >修改</el-button
  112. >
  113. <el-button
  114. @click="onDelete(scope.row)"
  115. v-permission="'cooperationOrgan/del'"
  116. type="text"
  117. >删除</el-button
  118. >
  119. </template>
  120. </el-table-column>
  121. </el-table>
  122. <pagination
  123. sync
  124. :total.sync="pageInfo.total"
  125. :page.sync="pageInfo.page"
  126. :limit.sync="pageInfo.limit"
  127. :page-sizes="pageInfo.page_size"
  128. @pagination="getList"
  129. />
  130. </div>
  131. </div>
  132. <el-dialog
  133. :title="formTitle[formActionTitle]"
  134. :visible.sync="teachingStatus"
  135. @close="onFormClose('ruleForm')"
  136. width="500px"
  137. >
  138. <el-form :model="form" :rules="rules" ref="ruleForm">
  139. <el-form-item
  140. label="单位名称"
  141. prop="name"
  142. :label-width="formLabelWidth"
  143. >
  144. <el-input v-model.trim="form.name" autocomplete="off"></el-input>
  145. </el-form-item>
  146. <el-form-item
  147. label="所属分部"
  148. prop="organId"
  149. :label-width="formLabelWidth"
  150. >
  151. <el-select
  152. v-model.trim="form.organId"
  153. @change="changeOrgan"
  154. filterable
  155. clearable
  156. >
  157. <el-option
  158. v-for="item in selects.branchs"
  159. :key="item.id"
  160. :label="item.name"
  161. :value="item.id"
  162. ></el-option>
  163. </el-select>
  164. </el-form-item>
  165. <el-form-item
  166. label="乐团主管"
  167. prop="educationUserId"
  168. :label-width="formLabelWidth"
  169. :rules="[{ required: true, message: '乐团主管不能为空' }]"
  170. >
  171. <el-select
  172. :disabled="!form.organId"
  173. v-model.trim="form.educationUserId"
  174. filterable
  175. clearable
  176. >
  177. <el-option
  178. v-for="(item, index) in educationList"
  179. :key="index"
  180. :label="item.realName"
  181. :value="item.userId"
  182. >
  183. <span style="float: left">{{ item.realName }}</span>
  184. <span style="float: right; color: #8492a6; font-size: 13px">{{
  185. String(item.userId)
  186. }}</span>
  187. </el-option>
  188. </el-select>
  189. </el-form-item>
  190. <el-form-item
  191. label="状态"
  192. prop="isEnable"
  193. :label-width="formLabelWidth"
  194. >
  195. <el-select v-model.trim="form.isEnable" filterable clearable>
  196. <el-option label="开启" :value="true"></el-option>
  197. <el-option label="关闭" :value="false"></el-option>
  198. </el-select>
  199. </el-form-item>
  200. <el-form-item
  201. label="联系人"
  202. prop="linkman"
  203. :label-width="formLabelWidth"
  204. >
  205. <el-input v-model.trim="form.linkman" autocomplete="off"></el-input>
  206. </el-form-item>
  207. <el-form-item label="职位" prop="job" :label-width="formLabelWidth">
  208. <el-input v-model.trim="form.job" autocomplete="off"></el-input>
  209. </el-form-item>
  210. <el-form-item
  211. label="手机号"
  212. prop="mobileNo"
  213. :label-width="formLabelWidth"
  214. >
  215. <el-input v-model.trim="form.mobileNo" autocomplete="off"></el-input>
  216. </el-form-item>
  217. <el-form-item
  218. label="是否全职资源"
  219. prop="fullJobResource"
  220. :label-width="formLabelWidth"
  221. >
  222. <el-select v-model.trim="form.fullJobResource">
  223. <el-option label="是" :value="1"></el-option>
  224. <el-option label="否" :value="0"></el-option>
  225. </el-select>
  226. </el-form-item>
  227. </el-form>
  228. <span slot="footer" class="dialog-footer">
  229. <el-button @click="teachingStatus = false">取 消</el-button>
  230. <el-button type="primary" @click="onTeachingSubmit('ruleForm')"
  231. >确 定</el-button
  232. >
  233. </span>
  234. </el-dialog>
  235. </div>
  236. </template>
  237. <script>
  238. import pagination from "@/components/Pagination/index";
  239. import {
  240. cooperationOrganAdd,
  241. cooperationOrganUpdate,
  242. cooperationOrganDel,
  243. queryPage,
  244. } from "@/api/systemManage";
  245. import cleanDeep from "clean-deep";
  246. import { isvalidPhone } from "@/utils/validate";
  247. import { Export } from "@/utils/downLoadFile";
  248. import { findUserByRole } from "@/api/buildTeam";
  249. import qs from "qs";
  250. let validPhone = (rule, value, callback) => {
  251. if (!value) {
  252. callback(new Error("请输入电话号码"));
  253. } else if (!isvalidPhone(value)) {
  254. callback(new Error("请输入正确的11位手机号码"));
  255. } else {
  256. callback();
  257. }
  258. };
  259. export default {
  260. name: "branchManager",
  261. components: { pagination },
  262. data() {
  263. return {
  264. searchForm: {
  265. organId: null,
  266. isEnable: null,
  267. search: null,
  268. },
  269. searchLsit: [],
  270. tableList: [],
  271. educationList: [],
  272. pageInfo: {
  273. // 分页规则
  274. limit: 10, // 限制显示条数
  275. page: 1, // 当前页
  276. total: 0, // 总条数
  277. page_size: [10, 20, 40, 50], // 选择限制显示条数
  278. },
  279. teachingStatus: false, // 添加教学点
  280. formActionTitle: "create",
  281. formTitle: {
  282. create: "添加合作单位",
  283. update: "修改合作单位",
  284. },
  285. formLabelWidth: "120px",
  286. form: {
  287. id: null,
  288. name: null, // 教学点名称
  289. linkman: null, // 来源
  290. job: null, // 费用
  291. mobileNo: null,
  292. fullJobResource: null,
  293. organId: null,
  294. educationUserId: null,
  295. },
  296. rules: {
  297. name: [
  298. { required: true, message: "请输入教学点名称", trigger: "blur" },
  299. ],
  300. linkman: [{ required: true, message: "请输入联系人", trigger: "blur" }],
  301. job: [{ required: true, message: "请输入职位", trigger: "blur" }],
  302. mobileNo: [
  303. { required: true, validator: validPhone, trigger: "blur" },
  304. ,
  305. {
  306. pattern: /^1[3456789]\d{9}$/,
  307. message: "请输入正确的手机号",
  308. trigger: "blur",
  309. },
  310. ],
  311. organId: [
  312. { required: true, message: "请选择所属分部", trigger: "change" },
  313. ],
  314. educationUserId: [
  315. { required: true, message: "请选择乐团主管", trigger: "change" },
  316. ],
  317. fullJobResource: [
  318. { required: true, message: "请选择是否全职资源", trigger: "change" },
  319. ],
  320. isEnable: [
  321. { required: true, message: "请选择状态", trigger: "change" },
  322. ],
  323. },
  324. };
  325. },
  326. mounted() {
  327. this.getList(); // 获取列表数据
  328. // 获取当前用户分部
  329. this.$store.dispatch("setBranchs");
  330. },
  331. methods: {
  332. onDelete(rows) {
  333. this.$confirm("您确定删除合作单位?", "提示", {
  334. confirmButtonText: "确定",
  335. cancelButtonText: "取消",
  336. type: "warning",
  337. })
  338. .then(() => {
  339. cooperationOrganDel(rows.id).then((res) => {
  340. if (res.code == 200) {
  341. this.$message.success("删除成功");
  342. this.teachingStatus = false;
  343. this.getList();
  344. } else {
  345. this.$message.error(res.msg);
  346. }
  347. });
  348. })
  349. .catch(() => {});
  350. },
  351. search() {
  352. this.pageInfo.page = 1;
  353. this.getList();
  354. },
  355. onReSet() {
  356. this.searchForm = {
  357. organId: null,
  358. isEnable: null,
  359. };
  360. this.search();
  361. },
  362. onExport() {
  363. Export(
  364. this,
  365. {
  366. url: "/api-web/export/cooperationOrgan",
  367. fileName: "合作单位.xls",
  368. method: "post",
  369. params: qs.stringify(cleanDeep(this.searchForm)),
  370. },
  371. "您确定导出合作单位?"
  372. );
  373. },
  374. onTeachingSubmit(formName) {
  375. // 添加数据
  376. this.$refs[formName].validate((valid) => {
  377. if (valid) {
  378. if (this.formActionTitle == "create") {
  379. if (this.form.id) {
  380. // 判断有没有Id,如果有则删除
  381. delete this.form.id;
  382. }
  383. cooperationOrganAdd(this.form).then((res) => {
  384. if (res.code == 200) {
  385. this.$message.success("创建成功");
  386. this.teachingStatus = false;
  387. this.getList();
  388. } else {
  389. this.$message.error(res.msg);
  390. }
  391. });
  392. } else if (this.formActionTitle == "update") {
  393. cooperationOrganUpdate(this.form).then((res) => {
  394. if (res.code == 200) {
  395. this.$message.success("修改成功");
  396. this.teachingStatus = false;
  397. this.getList();
  398. } else {
  399. this.$message.error(res.msg);
  400. }
  401. });
  402. }
  403. } else {
  404. return false;
  405. }
  406. });
  407. },
  408. getList() {
  409. queryPage({
  410. rows: this.pageInfo.limit,
  411. page: this.pageInfo.page,
  412. ...this.searchForm,
  413. }).then((res) => {
  414. if (res.code == 200 && res.data) {
  415. this.tableList = res.data.rows;
  416. this.pageInfo.total = res.data.total;
  417. }
  418. });
  419. },
  420. openTeaching(type, rows) {
  421. // 重置数据
  422. this.teachingStatus = true;
  423. this.formActionTitle = type;
  424. this.changeOrgan(rows.organId);
  425. // 修改的时候赋值
  426. if (type == "update") {
  427. this.form = {
  428. id: rows.id,
  429. name: rows.name, // 教学点名称
  430. linkman: rows.linkman, // 来源
  431. job: rows.job, // 费用
  432. mobileNo: rows.mobileNo ? rows.mobileNo : null,
  433. ownershipType: rows.ownershipType,
  434. organId: rows.organId,
  435. fullJobResource: rows.fullJobResource,
  436. isEnable: rows.isEnable,
  437. educationUserId: rows.educationUserId,
  438. };
  439. }
  440. },
  441. onFormClose(formName) {
  442. // 关闭弹窗重置验证
  443. // this.$refs[formName].clearValidate()
  444. this.form = {
  445. id: null,
  446. name: null, // 教学点名称
  447. linkman: null, // 来源
  448. job: null, // 费用
  449. mobileNo: null,
  450. fullJobResource: null,
  451. organId: null,
  452. isEnable: null,
  453. educationUserId: null,
  454. };
  455. this.$refs[formName].resetFields();
  456. },
  457. async changeOrgan(val) {
  458. this.form.educationUserId = null;
  459. if (val) {
  460. try {
  461. const ruselt = await findUserByRole({
  462. organId: val,
  463. employeeRole: "EDUCATION",
  464. });
  465. this.educationList = ruselt?.data?.EDUCATION;
  466. } catch (e) {
  467. console.log(e);
  468. }
  469. }
  470. },
  471. },
  472. };
  473. </script>
  474. <style lang="scss" scoped>
  475. .el-button--primary {
  476. background: #14928a;
  477. border-color: #14928a;
  478. color: #fff;
  479. &:hover,
  480. &:active,
  481. &:focus {
  482. background: #14928a;
  483. border-color: #14928a;
  484. color: #fff;
  485. }
  486. }
  487. /deep/.el-select {
  488. width: 100% !important;
  489. }
  490. .el-vue-search-box-container {
  491. position: absolute !important;
  492. left: 10px;
  493. margin-top: 10px;
  494. z-index: 99999 !important;
  495. }
  496. </style>