desktopToolList.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <template>
  2. <div class="desktopToolList">
  3. <div class="title_examine">
  4. <div class="pub_title">工具列表</div>
  5. <div class="t_right">
  6. <el-button type="primary" size="small" @click="addTool()"
  7. >添加工具</el-button
  8. >
  9. </div>
  10. </div>
  11. <div class="table_content tableArea">
  12. <div class="button_top">
  13. <div @click="changeStatus('')">全部({{ pageData.total }})</div>
  14. </div>
  15. <el-table
  16. :data="desktopList"
  17. stripe
  18. border
  19. style="width: 100%"
  20. v-loading="loading"
  21. :header-cell-style="headerCellStyle"
  22. >
  23. <el-table-column label="正式名称" min-width="45" show-overflow-tooltip>
  24. <template slot-scope="scope">{{
  25. scope.row.url[0].name ? scope.row.url[0].name : "-"
  26. }}</template>
  27. </el-table-column>
  28. <el-table-column label="标识" min-width="45" show-overflow-tooltip>
  29. <template slot-scope="scope">{{
  30. scope.row.toolId ? scope.row.toolId : "-"
  31. }}</template>
  32. </el-table-column>
  33. <el-table-column label="窗口宽度" min-width="45" show-overflow-tooltip>
  34. <template slot-scope="scope">{{
  35. scope.row.dialogWidth ? scope.row.dialogWidth : "-"
  36. }}</template>
  37. </el-table-column>
  38. <el-table-column label="窗口高度" min-width="45" show-overflow-tooltip>
  39. <template slot-scope="scope">{{
  40. scope.row.dialogHeight ? scope.row.dialogHeight : "-"
  41. }}</template>
  42. </el-table-column>
  43. <el-table-column label="描述" min-width="200" show-overflow-tooltip>
  44. <template slot-scope="scope">{{
  45. scope.row.description ? scope.row.description : "-"
  46. }}</template>
  47. </el-table-column>
  48. <el-table-column label="工具设置" width="102" show-overflow-tooltip>
  49. <template slot-scope="scope">
  50. <el-popover placement="bottom" width="840" trigger="hover">
  51. <div class="urlItemBox">
  52. <div
  53. class="urlItem"
  54. v-for="(item, index) in scope.row.url"
  55. :key="scope.row.id + '-' + index"
  56. >
  57. <span>{{ item.region }}</span>
  58. <div class="ui_message">
  59. <div>名称:{{ item.name ? item.name : "-" }}</div>
  60. <div>
  61. <span>链接:</span
  62. ><a :href="item.url" v-if="item.url" target="_blank">{{
  63. item.url
  64. }}</a
  65. ><span v-else>-</span>
  66. </div>
  67. <div>
  68. <span>桌面图标:</span>
  69. <div class="ui_m_image">
  70. <el-image
  71. v-if="item.icon"
  72. style="width: 100%; height: 100%"
  73. :src="item.icon"
  74. fit="cover"
  75. ></el-image>
  76. <span v-else>-</span>
  77. </div>
  78. </div>
  79. <div>
  80. <span>平台图标:</span>
  81. <div class="ui_m_image">
  82. <el-image
  83. v-if="item.platformIcon"
  84. style="width: 100%; height: 100%"
  85. :src="item.platformIcon"
  86. fit="cover"
  87. ></el-image>
  88. <span v-else>-</span>
  89. </div>
  90. </div>
  91. <div>
  92. <span>默认图标:</span>
  93. <div class="ui_m_image">
  94. <el-image
  95. v-if="item.defaultIcon"
  96. style="width: 100%; height: 100%"
  97. :src="item.defaultIcon"
  98. fit="cover"
  99. ></el-image>
  100. <span v-else>-</span>
  101. </div>
  102. </div>
  103. <div>
  104. <span>激活图标:</span>
  105. <div class="ui_m_image">
  106. <el-image
  107. v-if="item.activeIcon"
  108. style="width: 100%; height: 100%"
  109. :src="item.activeIcon"
  110. fit="cover"
  111. ></el-image>
  112. <span v-else>-</span>
  113. </div>
  114. </div>
  115. <div>
  116. <span>激活图标:</span>
  117. <div class="ui_m_image">
  118. <el-image
  119. v-if="item.hoverIcon"
  120. style="width: 100%; height: 100%"
  121. :src="item.hoverIcon"
  122. fit="cover"
  123. ></el-image>
  124. <span v-else>-</span>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. <el-button slot="reference" size="small">查看设置</el-button>
  131. </el-popover>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="参数" min-width="150" show-overflow-tooltip>
  135. <template slot-scope="scope">
  136. <div v-if="scope.row.argumentList.length">
  137. <el-tag
  138. v-for="(item, index) in scope.row.argumentList"
  139. :key="index"
  140. style="margin-right: 10px"
  141. effect="plain"
  142. >{{ item }}</el-tag
  143. >
  144. </div>
  145. <span v-else>-</span>
  146. </template>
  147. </el-table-column>
  148. <el-table-column
  149. label="仅管理员显示"
  150. min-width="45"
  151. show-overflow-tooltip
  152. >
  153. <template slot-scope="scope">{{
  154. scope.row.isAdmin == "1" ? "是" : "否"
  155. }}</template>
  156. </el-table-column>
  157. <el-table-column label="工具状态" min-width="50" show-overflow-tooltip>
  158. <template slot-scope="scope">{{
  159. statusList[scope.row.status]
  160. }}</template>
  161. </el-table-column>
  162. <el-table-column label="操作" width="240px" show-overflow-tooltip>
  163. <template slot-scope="scope">
  164. <button
  165. @click="editTool(scope.row)"
  166. style="
  167. color: #308fff;
  168. background: none;
  169. border: none;
  170. cursor: pointer;
  171. margin-left: 25px;
  172. "
  173. >
  174. 修改
  175. </button>
  176. <button
  177. v-if="scope.row.status == '0'"
  178. @click="changeToolStatus(scope.row, '1')"
  179. style="
  180. color: #ff2570;
  181. background: none;
  182. border: none;
  183. cursor: pointer;
  184. margin-left: 25px;
  185. "
  186. >
  187. 停用
  188. </button>
  189. <button
  190. v-if="scope.row.status == '1'"
  191. @click="changeToolStatus(scope.row, '0')"
  192. style="
  193. color: #67c23a;
  194. background: none;
  195. border: none;
  196. cursor: pointer;
  197. margin-left: 25px;
  198. "
  199. >
  200. 启用
  201. </button>
  202. <button
  203. @click="copyTool(scope.row)"
  204. style="
  205. color: #308fff;
  206. background: none;
  207. border: none;
  208. cursor: pointer;
  209. margin-left: 25px;
  210. "
  211. >
  212. 复制
  213. </button>
  214. <button
  215. @click="delTool(scope.row)"
  216. style="
  217. color: #ff2570;
  218. background: none;
  219. border: none;
  220. cursor: pointer;
  221. margin-left: 25px;
  222. "
  223. >
  224. 删除
  225. </button>
  226. </template>
  227. </el-table-column>
  228. </el-table>
  229. <el-pagination
  230. style="margin-top: 10px"
  231. :current-page="pageData.nowPage"
  232. :page-size="pageData.lim"
  233. :total="pageData.total"
  234. @current-change="handlePageChange"
  235. layout="total,prev, pager, next, jumper"
  236. >
  237. </el-pagination>
  238. </div>
  239. <addDesktopToolDialog
  240. ref="addDesktopToolDialogRef"
  241. @success="addDesktopToolSuccess"
  242. />
  243. </div>
  244. </template>
  245. <script>
  246. import { API_CONFIG } from "@/common/apiConfig";
  247. import addDesktopToolDialog from "./dialog/addDesktopToolDialog.vue";
  248. import { addOp } from "@/api/user";
  249. import { mapGetters } from "vuex";
  250. export default {
  251. components: {
  252. addDesktopToolDialog,
  253. },
  254. computed: {
  255. ...mapGetters(["userid"]),
  256. },
  257. data() {
  258. return {
  259. desktopList: [],
  260. selectStatus: "",
  261. pageData: {
  262. nowPage: 1,
  263. lim: 10,
  264. total: 0,
  265. },
  266. loading: false,
  267. statusList: ["正常使用", "已停用", "已删除"],
  268. };
  269. },
  270. methods: {
  271. // 表头的背景色
  272. headerCellStyle() {
  273. return { backgroundColor: "#f1f1f1" };
  274. },
  275. //获取数据
  276. getData() {
  277. let params = [
  278. {
  279. functionName: "select_desktopToolByPage",
  280. status: this.selectStatus,
  281. page: this.pageData.nowPage,
  282. lim: this.pageData.lim,
  283. },
  284. ];
  285. this.loading = true;
  286. this.$ajax
  287. .post(API_CONFIG.baseUrl, params)
  288. .then((res) => {
  289. let _data = res.data;
  290. let _list = _data[0];
  291. let _total = _data[1][0].total;
  292. _list.forEach((i) => {
  293. i.url = JSON.parse(i.url);
  294. i.json = JSON.parse(i.json);
  295. i.argumentList = JSON.parse(i.argumentList);
  296. });
  297. this.desktopList = _list;
  298. this.pageData.total = _total;
  299. this.loading = false;
  300. // console.log(_data)
  301. })
  302. .catch((err) => {
  303. console.log(err);
  304. this.loading = false;
  305. this.$message.error("获取工具数据失败");
  306. });
  307. },
  308. handlePageChange(newPage) {
  309. this.pageData.nowPage = newPage;
  310. this.getData();
  311. },
  312. addTool() {
  313. this.$refs.addDesktopToolDialogRef.open();
  314. },
  315. addDesktopToolSuccess(form) {
  316. if (form.id) {
  317. let params = [
  318. {
  319. functionName: "update_desktopToolById",
  320. id: form.id,
  321. toolId: form.toolId,
  322. width: form.dialogWidth,
  323. height: form.dialogHeight,
  324. description: form.description,
  325. admin: form.isAdmin,
  326. argumentList: JSON.stringify(form.argumentList),
  327. url: JSON.stringify(form.url),
  328. json: JSON.stringify(form.json),
  329. status: form.status,
  330. },
  331. ];
  332. this.$refs.addDesktopToolDialogRef.loading = true;
  333. this.$ajax
  334. .post(API_CONFIG.baseUrl, params)
  335. .then(async (res) => {
  336. if (res.data == 1) {
  337. this.$refs.addDesktopToolDialogRef.close();
  338. this.$message.success("修改工具成功");
  339. await addOp({
  340. uid: this.userid,
  341. cid: "",
  342. type: "user_op",
  343. content: `修改了了工具:${form.toolId}`,
  344. });
  345. } else if (res.data[0][0].message == "repeat toolId") {
  346. this.$message.error("工具标识重复!");
  347. } else {
  348. this.$message.error("修改工具失败");
  349. }
  350. this.$refs.addDesktopToolDialogRef.loading = false;
  351. this.getData();
  352. })
  353. .catch((err) => {
  354. console.log(err);
  355. this.$message.error("修改工具失败");
  356. this.$refs.addDesktopToolDialogRef.loading = false;
  357. });
  358. } else {
  359. let params = [
  360. {
  361. functionName: "insert_desktopTool",
  362. toolId: form.toolId,
  363. width: form.dialogWidth,
  364. height: form.dialogHeight,
  365. description: form.description,
  366. admin: form.isAdmin,
  367. argumentList: JSON.stringify(form.argumentList),
  368. url: JSON.stringify(form.url),
  369. json: JSON.stringify(form.json),
  370. },
  371. ];
  372. this.$refs.addDesktopToolDialogRef.loading = true;
  373. this.$ajax
  374. .post(API_CONFIG.baseUrl, params)
  375. .then(async (res) => {
  376. console.log(res);
  377. if (res.data == 1) {
  378. this.$refs.addDesktopToolDialogRef.close();
  379. this.$message.success("添加工具成功");
  380. await addOp({
  381. uid: this.userid,
  382. cid: "",
  383. type: "user_op",
  384. content: `添加了工具:${form.toolId}`,
  385. });
  386. } else if (res.data[0][0].message == "repeat toolId") {
  387. this.$message.error("工具标识重复!");
  388. } else {
  389. this.$message.error("添加工具失败");
  390. }
  391. this.$refs.addDesktopToolDialogRef.loading = false;
  392. this.getData();
  393. })
  394. .catch((err) => {
  395. console.log(err);
  396. this.$message.error("添加工具失败");
  397. this.$refs.addDesktopToolDialogRef.loading = false;
  398. });
  399. }
  400. },
  401. editTool(item) {
  402. this.$refs.addDesktopToolDialogRef.open(item);
  403. },
  404. changeStatus() {
  405. this.pageData.nowPage = 1;
  406. this.getData();
  407. },
  408. changeToolStatus(item, newValue) {
  409. let _data = JSON.parse(JSON.stringify(item));
  410. _data.status = newValue;
  411. this.loading = true;
  412. let params = [
  413. {
  414. functionName: "update_desktopToolById",
  415. id: _data.id,
  416. toolId: _data.toolId,
  417. width: _data.dialogWidth,
  418. height: _data.dialogHeight,
  419. description: _data.description,
  420. admin: _data.isAdmin,
  421. argumentList: JSON.stringify(_data.argumentList),
  422. url: JSON.stringify(_data.url),
  423. json: JSON.stringify(_data.json),
  424. status: _data.status,
  425. },
  426. ];
  427. this.$ajax
  428. .post(API_CONFIG.baseUrl, params)
  429. .then(async (res) => {
  430. if (res.data == 1) {
  431. if (newValue == 1) {
  432. this.$message.success("已停用");
  433. await addOp({
  434. uid: this.userid,
  435. cid: "",
  436. type: "user_op",
  437. content: `停用了工具:${item.toolId}`,
  438. });
  439. } else {
  440. this.$message.success("已启用");
  441. await addOp({
  442. uid: this.userid,
  443. cid: "",
  444. type: "user_op",
  445. content: `启用了工具:${item.toolId}`,
  446. });
  447. }
  448. } else {
  449. if (newValue == 1) {
  450. this.$message.success("停用失败");
  451. } else {
  452. this.$message.success("启用失败");
  453. }
  454. }
  455. this.loading = false;
  456. this.getData();
  457. })
  458. .catch((err) => {
  459. console.log(err);
  460. this.loading = false;
  461. this.$message.error("停用失败");
  462. });
  463. },
  464. copyTool(data) {
  465. let _copyData = JSON.parse(JSON.stringify(data));
  466. console.log("👉", _copyData);
  467. _copyData.toolId = _copyData.toolId + "_copy";
  468. _copyData.description = _copyData.description + "_copy";
  469. delete _copyData.id;
  470. this.$refs.addDesktopToolDialogRef.open(_copyData);
  471. },
  472. delTool(data) {
  473. this.$confirm("此操作将永久删除该工具,是否继续?", "删除工具", {
  474. confirmButtonText: "确定",
  475. cancelButtonText: "取消",
  476. type: "warning",
  477. })
  478. .then(() => {
  479. let params = [
  480. {
  481. functionName: "delete_desktopToolById",
  482. id: data.id,
  483. },
  484. ];
  485. this.$ajax
  486. .post(API_CONFIG.baseUrl, params)
  487. .then(async (res) => {
  488. console.log(res);
  489. if (res.data == 1) {
  490. this.$message.success("删除工具成功");
  491. await addOp({
  492. uid: this.userid,
  493. cid: "",
  494. type: "user_op",
  495. content: `删除了了工具:${data.toolId}-${data.id}`,
  496. });
  497. }else{
  498. this.$message.error("删除工具失败");
  499. }
  500. this.getData();
  501. })
  502. .catch((err) => {
  503. console.log(err);
  504. this.$message.error("删除工具失败");
  505. this.getData();
  506. });
  507. })
  508. .catch(() => {});
  509. },
  510. },
  511. mounted() {
  512. this.getData();
  513. },
  514. };
  515. </script>
  516. <style scoped>
  517. .desktopToolList {
  518. width: 100%;
  519. height: 100%;
  520. box-sizing: border-box;
  521. padding: 10px;
  522. overflow: auto;
  523. }
  524. .tableArea {
  525. margin: 10px 0;
  526. }
  527. .button_top {
  528. width: 100%;
  529. display: flex;
  530. align-items: center;
  531. margin: 10px 0;
  532. }
  533. .button_top > div {
  534. font-weight: bold;
  535. margin-right: 20px;
  536. cursor: pointer;
  537. }
  538. .title_examine {
  539. display: flex;
  540. justify-content: space-between;
  541. }
  542. .urlItemBox {
  543. display: flex;
  544. flex-wrap: wrap;
  545. }
  546. .urlItem {
  547. width: 400px;
  548. height: 300px;
  549. overflow: auto;
  550. position: relative;
  551. box-sizing: border-box;
  552. border-bottom: solid 1px #ebeef5;
  553. }
  554. .urlItem:nth-child(2n) {
  555. margin-left: 20px;
  556. }
  557. .urlItem > span {
  558. font-size: 18px;
  559. font-weight: bold;
  560. }
  561. .ui_m_image {
  562. width: 40px;
  563. height: 40px;
  564. float: left;
  565. display: flex;
  566. align-items: center;
  567. }
  568. .ui_message > div {
  569. display: flex;
  570. align-items: center;
  571. }
  572. .ui_message > div > span {
  573. white-space: nowrap;
  574. }
  575. </style>