Grid.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <style lang="scss">
  2. .staff {
  3. display: flex;
  4. justify-content: space-between;
  5. .companies {
  6. height: 75vh;
  7. overflow: auto;
  8. margin-right: 10px;
  9. overflow-x: hidden;
  10. }
  11. & > li {
  12. width: 30%;
  13. list-style: none;
  14. min-height: 70vh;
  15. background: #fff;
  16. border: 1px solid #d9d9d9;
  17. padding: 20px 10px;
  18. }
  19. .custom-tree-node {
  20. width: 100%;
  21. .el-tree-node__content {
  22. height: 32px;
  23. }
  24. .label_name {
  25. font-size: 14px;
  26. }
  27. .active {
  28. color: #1989fa;
  29. }
  30. .edit {
  31. float: right;
  32. i {
  33. font-weight: bolder;
  34. font-size: 14px;
  35. }
  36. }
  37. }
  38. .staff_list {
  39. width: 68%;
  40. .grid_item {
  41. height: 60vh;
  42. border: 1px solid #ccc;
  43. text-align: center;
  44. .el-input--mini {
  45. width: 90%;
  46. margin-top: 10px;
  47. padding-right: 5px;
  48. }
  49. .el-button--primary {
  50. width: 90%;
  51. margin-top: 20px;
  52. }
  53. }
  54. }
  55. }
  56. .staffs {
  57. margin-right: 10px;
  58. }
  59. // 企业端
  60. .qy_content {
  61. background: #151932;
  62. width: 100%;
  63. height: 90vh;
  64. margin-top: 10px;
  65. .grid-item {
  66. padding: 20px;
  67. color: #fff;
  68. }
  69. .intro {
  70. height: 90vh;
  71. overflow-y: scroll;
  72. line-height: 25px;
  73. }
  74. }
  75. .w-e-text-container {
  76. height: 600px;
  77. }
  78. .bg-color-blue {
  79. color: #fff;
  80. background-color: #388cff;
  81. }
  82. .org-tree-container {
  83. background: none;
  84. }
  85. .gridDetail {
  86. .el-dialog__header {
  87. background: #2d3a67;
  88. .el-dialog__title {
  89. color: #fff;
  90. }
  91. }
  92. .el-dialog__body {
  93. background: #2d3a67;
  94. padding: 10px 20px;
  95. table {
  96. td {
  97. padding: 10px;
  98. color: #fff;
  99. text-align: center;
  100. img {
  101. border-radius: 3px;
  102. }
  103. h4 {
  104. color: #30ceee;
  105. }
  106. }
  107. }
  108. }
  109. .el-dialog__footer {
  110. background: #2d3a67;
  111. }
  112. }
  113. .custom-tree-node {
  114. flex: 1;
  115. display: flex;
  116. align-items: center;
  117. justify-content: space-between;
  118. font-size: 14px;
  119. padding-right: 8px;
  120. }
  121. </style>
  122. <template>
  123. <section>
  124. <p>公司管理 > 网格化管理</p>
  125. <!-- 管理员端 -->
  126. <div v-if="utype == 0">
  127. <div class="content">
  128. <ul class="staff">
  129. <li class="companies">
  130. <el-form size="small">
  131. <el-form-item>
  132. <el-input
  133. suffix-icon="el-icon-search"
  134. v-model="name"
  135. @change="getData"
  136. placeholder="公司名称"
  137. ></el-input>
  138. </el-form-item>
  139. </el-form>
  140. <el-tree
  141. :data="data"
  142. node-key="id"
  143. :props="props"
  144. :expand-on-click-node="false"
  145. >
  146. <span
  147. class="custom-tree-node"
  148. slot-scope="{ node, data }"
  149. @click="change(data)"
  150. >
  151. <span v-if="id == data.id" class="label_name active">{{
  152. node.label
  153. }}</span>
  154. <span v-else class="label_name">{{ node.label }}</span>
  155. </span>
  156. </el-tree>
  157. </li>
  158. <li class="staff_list">
  159. <el-form
  160. label-width="70px"
  161. :inline="true"
  162. size="small"
  163. label-position="left"
  164. >
  165. <el-form-item>
  166. <el-button
  167. icon="el-icon-plus"
  168. @click="getEnterpriseInfo"
  169. type="primary"
  170. size="mini"
  171. >安全生产网格化管理简介</el-button
  172. >
  173. <el-button
  174. @click="getEnterpriseInfo"
  175. type="primary"
  176. size="mini"
  177. >导入组织机构</el-button
  178. >
  179. </el-form-item>
  180. </el-form>
  181. <div>
  182. <!-- 暂时注释 -->
  183. <!-- <div class="grid_item" style="width: 15%">
  184. <div
  185. style="position: relative"
  186. v-for="item in gridList"
  187. :key="item.id"
  188. >
  189. <el-input
  190. v-model="item.label"
  191. placeholder="请输入"
  192. size="mini"
  193. >
  194. <el-button
  195. slot="append"
  196. icon="el-icon-edit"
  197. size="mini"
  198. @click="editGridDetail(item)"
  199. ></el-button>
  200. </el-input>
  201. <i
  202. class="el-icon-arrow-right"
  203. style="
  204. position: absolute;
  205. top: 15px;
  206. right: 1px;
  207. cursor: pointer;
  208. "
  209. ></i>
  210. </div>
  211. <el-button type="primary" size="mini">添加</el-button>
  212. </div> -->
  213. <el-tree
  214. :data="gridList"
  215. node-key="id"
  216. default-expand-all
  217. :expand-on-click-node="false">
  218. <span class="custom-tree-node" slot-scope="{ node, data }">
  219. <span>{{ node.label }}</span>
  220. <span>
  221. <!-- <el-button
  222. type="text"
  223. size="mini"
  224. @click="() => append(data)">
  225. Append
  226. </el-button> -->
  227. <el-button
  228. type="text"
  229. size="mini"
  230. @click="() => editGridDetail(node, data)">
  231. 编辑
  232. </el-button>
  233. </span>
  234. </span>
  235. </el-tree>
  236. </div>
  237. </li>
  238. </ul>
  239. </div>
  240. <el-dialog
  241. :title="'编辑' + curItem.label"
  242. :visible.sync="dialogFormVisible1"
  243. width="1000px"
  244. :close-on-click-modal="false"
  245. :close-on-press-escape="false"
  246. >
  247. <el-form size="small" label-width="120px">
  248. <el-row :gutter="10">
  249. <el-col :span="8">
  250. <el-form-item label="负责人姓名">
  251. <el-input
  252. v-model="form1.charge_person_name"
  253. placeholder="请输入负责人姓名"
  254. ></el-input>
  255. </el-form-item>
  256. </el-col>
  257. <el-col :span="8">
  258. <el-form-item label="负责人电话">
  259. <el-input
  260. v-model="form1.charge_person_phone"
  261. placeholder="请输入负责人手机号"
  262. ></el-input>
  263. </el-form-item>
  264. </el-col>
  265. <el-col :span="8">
  266. <el-form-item label="车牌号">
  267. <el-input
  268. v-model="form1.car_number"
  269. placeholder="仅配送相关职位填写"
  270. ></el-input>
  271. </el-form-item>
  272. </el-col>
  273. <el-col :span="8">
  274. <el-form-item label="负责人照片">
  275. <div class="upload_div">
  276. <i
  277. v-if="form1.charge_person_photo"
  278. @click="form1.charge_person_photo = ''"
  279. class="el-icon-delete"
  280. ></i>
  281. <i class="el-icon-upload"></i>
  282. <img
  283. v-if="form1.charge_person_photo"
  284. width="100%"
  285. height="100%"
  286. :src="form1.charge_person_photo"
  287. alt=""
  288. />
  289. <input
  290. accept="image/png,image/jpg"
  291. @change="upload('charge_person_photo')"
  292. id="charge_person_photo"
  293. type="file"
  294. />
  295. </div>
  296. </el-form-item>
  297. </el-col>
  298. <el-col :span="8">
  299. <el-form-item label="证件类型">
  300. <div class="upload_div">
  301. <i
  302. v-if="form1.certificate"
  303. @click="form1.certificate = ''"
  304. class="el-icon-delete"
  305. ></i>
  306. <i class="el-icon-upload"></i>
  307. <img
  308. v-if="form1.certificate"
  309. width="100%"
  310. height="100%"
  311. :src="form1.certificate"
  312. alt=""
  313. />
  314. <input
  315. accept="image/png,image/jpg"
  316. @change="upload('certificate')"
  317. id="certificate"
  318. type="file"
  319. />
  320. </div>
  321. </el-form-item>
  322. </el-col>
  323. </el-row>
  324. <el-form-item label="责任清单">
  325. <!-- <el-input
  326. type="textarea"
  327. v-model="form1.duty_list"
  328. placeholder=""
  329. rows="10"
  330. ></el-input> -->
  331. <fuEditor v-model="form1.duty_list" :isClear="isClear"></fuEditor>
  332. </el-form-item>
  333. <el-form-item label="履职清单">
  334. <!-- <el-input
  335. type="textarea"
  336. v-model="form1.job_list"
  337. placeholder=""
  338. rows="10"
  339. ></el-input> -->
  340. <fuEditor v-model="form1.job_list" :isClear="isClear"></fuEditor>
  341. </el-form-item>
  342. <el-form-item label="部门职责">
  343. <!-- <el-input
  344. type="textarea"
  345. v-model="form1.depart_list"
  346. placeholder=""
  347. rows="10"
  348. ></el-input> -->
  349. <fuEditor v-model="form1.depart_list" :isClear="isClear"></fuEditor>
  350. </el-form-item>
  351. </el-form>
  352. <div slot="footer" class="dialog-footer">
  353. <el-button size="small" @click="dialogFormVisible1 = false"
  354. >取 消</el-button
  355. >
  356. <el-button size="small" type="primary" @click="saveGridDetail"
  357. >确 定</el-button
  358. >
  359. </div>
  360. </el-dialog>
  361. <el-dialog
  362. title="安全生产网格化管理简介"
  363. :visible.sync="dialogFormVisible2"
  364. >
  365. <div>
  366. <fuEditor v-model="form.grid_security" :isClear="isClear"></fuEditor>
  367. </div>
  368. <div slot="footer">
  369. <el-button @click="dialogFormVisible2 = false">取 消</el-button>
  370. <el-button type="primary" @click="updateEnterprise">确 定</el-button>
  371. </div>
  372. </el-dialog>
  373. </div>
  374. <!-- 企业端 -->
  375. <div class="qy_content" v-else>
  376. <el-row :gutter="10">
  377. <el-col :span="12">
  378. <div
  379. class="grid-item intro"
  380. v-html="enterpriseInfo.grid_security"
  381. ></div>
  382. </el-col>
  383. <el-col :span="12">
  384. <div class="grid-item grid_chart">
  385. <h2 align="center" style="margin-bottom: 10vh">
  386. 安全生产管理"一网通"
  387. </h2>
  388. <vue2-org-tree
  389. :data="treeData"
  390. :label-class-name="labelClassName"
  391. @on-node-click="nodeClick"
  392. />
  393. </div>
  394. </el-col>
  395. </el-row>
  396. <el-dialog
  397. title="责任详情"
  398. :visible.sync="dialogFormVisible3"
  399. width="600px"
  400. class="gridDetail"
  401. >
  402. <div>
  403. <table width="100%" border="1" cellspacing="0" cellpadding="0">
  404. <tr>
  405. <td style="text-align: left; padding-left: 10px">
  406. <p>姓名:</p>
  407. <p>{{ form1.charge_person_name }}</p>
  408. </td>
  409. <td rowspan="2">
  410. <img :src="form1.charge_person_photo" width="80" alt="" />
  411. </td>
  412. <td rowspan="2">
  413. <img :src="form1.certificate" width="180" alt="" />
  414. </td>
  415. </tr>
  416. <tr>
  417. <td style="text-align: left; padding-left: 10px">
  418. <p>手机:</p>
  419. <p>{{ form1.charge_person_phone }}</p>
  420. </td>
  421. </tr>
  422. <tr>
  423. <td colspan="3">
  424. <h4 align="left" style="">责任清单</h4>
  425. <div style="height: 200px" v-html="form1.duty_list">
  426. </div>
  427. </td>
  428. </tr>
  429. <tr>
  430. <td colspan="3">
  431. <h4 align="left" style="">履职清单</h4>
  432. <div style="height: 200px" v-html="form1.job_list">
  433. </div>
  434. </td>
  435. </tr>
  436. <tr>
  437. <td colspan="3">
  438. <h4 align="left" style="">部门职责</h4>
  439. <div style="height: 200px" v-html="form1.depart_list">
  440. </div>
  441. </td>
  442. </tr>
  443. </table>
  444. </div>
  445. <div slot="footer">
  446. <el-button @click="dialogFormVisible3 = false" size="mini"
  447. >取 消</el-button
  448. >
  449. <el-button
  450. type="primary"
  451. @click="dialogFormVisible3 = false"
  452. size="mini"
  453. >确 定</el-button
  454. >
  455. </div>
  456. </el-dialog>
  457. </div>
  458. </section>
  459. </template>
  460. <script>
  461. import Page from "../../components/Page";
  462. import fuEditor from "@/components/fuEditor/index.vue";
  463. export default {
  464. components: {
  465. Page,
  466. fuEditor,
  467. },
  468. data() {
  469. return {
  470. isClear: false,
  471. dialogFormVisible: false,
  472. dialogFormVisible1: false,
  473. dialogFormVisible2: false,
  474. dialogFormVisible3: false,
  475. data: [],
  476. form: { page: 1, page_size: 20 },
  477. list: [],
  478. total: 1,
  479. loading: false,
  480. props: {
  481. label: "name",
  482. },
  483. id: "",
  484. dpt: { enterprise_name: "", enterprise_id: "", staffusers: [] },
  485. enterprise_name: "",
  486. name: "",
  487. staff: {},
  488. dptList: [],
  489. form1: {},
  490. gridList: [],
  491. utype: localStorage.getItem("utype", 0),
  492. treeData1: {
  493. value: 0,
  494. label: "公司主要负责人",
  495. children: [
  496. {
  497. value: 2,
  498. label: "安全科",
  499. children: [
  500. {
  501. value: 5,
  502. label: "仓库运行班",
  503. children: [
  504. {
  505. value: 7,
  506. label: "储存员",
  507. },
  508. {
  509. value: 11,
  510. label: "搬运员",
  511. },
  512. {
  513. value: 12,
  514. label: "守护员",
  515. },
  516. ],
  517. },
  518. {
  519. value: 6,
  520. label: "销售科",
  521. children: [
  522. {
  523. value: 12,
  524. label: "甲销售员",
  525. },
  526. {
  527. value: 12,
  528. label: "乙销售员",
  529. },
  530. ],
  531. },
  532. {
  533. value: 9,
  534. label: "配送队",
  535. children: [
  536. {
  537. value: 12,
  538. label: "甲配送员",
  539. },
  540. {
  541. value: 12,
  542. label: "乙配送员",
  543. },
  544. ],
  545. },
  546. ],
  547. },
  548. ],
  549. },
  550. enterpriseInfo: {},
  551. labelClassName: "bg-color-blue",
  552. curItem: {},
  553. treeData: {},
  554. gridDetail: {},
  555. };
  556. },
  557. methods: {
  558. getEnterpriseInfo() {
  559. this.$api.getEnterprise({ id: this.form.enterprise_id }).then((res) => {
  560. this.dialogFormVisible2 = true;
  561. this.form.grid_security = res.data.data.grid_security;
  562. this.enterpriseInfo = res.data.data;
  563. });
  564. },
  565. updateEnterprise() {
  566. let params = {
  567. id: this.form.enterprise_id,
  568. grid_security: this.form.grid_security,
  569. name: this.form.enterprise_name,
  570. };
  571. this.$api.updateEnterprise(params).then((res) => {
  572. this.dialogFormVisible2 = false;
  573. });
  574. },
  575. gopage(size) {
  576. if (size) {
  577. this.form.page_size = size;
  578. }
  579. this.form.page = this.$refs.pageButton.page;
  580. this.getData();
  581. },
  582. change(data) {
  583. this.id = data.id;
  584. this.enterprise_name = data.name;
  585. this.getDpt();
  586. // this.$api.getDepartmentList({ enterprise_id: data.id }).then((res) => {
  587. // this.dptList = res.data.data.list;
  588. // });
  589. this.form.enterprise_id = data.id;
  590. this.form.enterprise_name = data.name;
  591. this.$api.getEnterprise({ id: this.form.enterprise_id }).then((res) => {
  592. this.form.grid_security = res.data.data.grid_security;
  593. this.enterpriseInfo = res.data.data;
  594. });
  595. // 机构树
  596. this.$api.getGridTree({ enterprise_id: this.id }).then((res) => {
  597. this.treeData = res.data.data;
  598. if (res.data.data) {
  599. this.gridList =
  600. typeof res.data.data == "object" ? [res.data.data] : res.data.data;
  601. }
  602. });
  603. },
  604. getData() {
  605. this.loading = true;
  606. this.$api.getEnterpriseList({ name: this.name }).then((res) => {
  607. this.data = res.data.data.list;
  608. this.change(this.data[0]);
  609. });
  610. },
  611. //获取员工列表
  612. getDpt() {
  613. var parm = this.form;
  614. parm.enterprise_id = this.id;
  615. // this.$api.getStaffuserList(parm).then((res) => {
  616. // this.loading = false;
  617. // this.list = res.data.data.list;
  618. // this.total = res.data.data.total;
  619. // });
  620. },
  621. del(id) {
  622. this.$confirm("确定删除吗", "提示", {
  623. type: "warning",
  624. }).then(() => {
  625. this.$api.deleteStaffuser({ id: id }).then((res) => {
  626. this.$message({
  627. message: "删除成功",
  628. type: "success",
  629. });
  630. this.getDpt();
  631. });
  632. });
  633. },
  634. saveGridDetail() {
  635. let params = this.form1;
  636. params.enterprise_grid_id = this.curItem.id;
  637. if (params.id) {
  638. this.$api.updateGridDetail(params).then((res) => {
  639. if (res.data.code != 0) {
  640. this.$message.error(res.data.message);
  641. }
  642. this.dialogFormVisible1 = false;
  643. });
  644. } else {
  645. this.$api.addGridDetail(params).then((res) => {
  646. if (res.data.code != 0) {
  647. this.$message.error(res.data.message);
  648. }
  649. this.dialogFormVisible1 = false;
  650. });
  651. }
  652. },
  653. handleClose(index) {
  654. this.dpt.staffusers.splice(index, 1);
  655. },
  656. edit(data) {
  657. this.dialogFormVisible1 = true;
  658. this.staff = { ...data };
  659. },
  660. editGridDetail(node,item) {
  661. if (!item.label) {
  662. this.$message.error("请先填写名称再编辑!");
  663. return;
  664. }
  665. this.dialogFormVisible1 = true;
  666. this.curItem = item;
  667. this.$api.getGridDetail({ id: item.id }).then((res) => {
  668. this.form1 = res.data.data?res.data.data:{};
  669. });
  670. },
  671. upload(type) {
  672. var file = document.getElementById(type).files;
  673. var data = new FormData();
  674. data.append("file", file[0]);
  675. this.$api.uploadFile(data).then((res) => {
  676. if (res.data.code == 0) {
  677. let form = this.form1;
  678. this.$set(form, type, res.data.data.url);
  679. this.$message({ message: "上传成功!", type: "success" });
  680. } else {
  681. this.$message.error(res.data.message);
  682. }
  683. });
  684. },
  685. nodeClick(e, data) {
  686. this.$api.getGridDetail({ id: data.value }).then((res) => {
  687. this.form1 = res.data.data;
  688. this.dialogFormVisible3 = true;
  689. });
  690. },
  691. },
  692. created() {
  693. this.getData();
  694. },
  695. };
  696. </script>