desktopToolList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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.toolId ? scope.row.toolId : "-"
  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.dialogWidth ? scope.row.dialogWidth : "-"
  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.dialogHeight ? scope.row.dialogHeight : "-"
  36. }}</template>
  37. </el-table-column>
  38. <el-table-column label="描述" min-width="200" show-overflow-tooltip>
  39. <template slot-scope="scope">{{
  40. scope.row.description ? scope.row.description : "-"
  41. }}</template>
  42. </el-table-column>
  43. <el-table-column label="工具设置" min-width="45" show-overflow-tooltip>
  44. <template slot-scope="scope">
  45. <el-popover placement="bottom" width="840" trigger="hover">
  46. <div class="urlItemBox">
  47. <div
  48. class="urlItem"
  49. v-for="(item, index) in scope.row.url"
  50. :key="scope.row.id + '-' + index"
  51. >
  52. <span>{{ item.region }}</span>
  53. <div class="ui_message">
  54. <div>名称:{{ item.name ? item.name : "-" }}</div>
  55. <div>
  56. <span>链接:</span
  57. ><a :href="item.url" v-if="item.url" target="_blank">{{
  58. item.url
  59. }}</a
  60. ><span v-else>-</span>
  61. </div>
  62. <div>
  63. <span>桌面图标:</span>
  64. <div class="ui_m_image">
  65. <el-image
  66. v-if="item.icon"
  67. style="width: 100%; height: 100%"
  68. :src="item.icon"
  69. fit="cover"
  70. ></el-image>
  71. <span v-else>-</span>
  72. </div>
  73. </div>
  74. <div>
  75. <span>平台图标:</span>
  76. <div class="ui_m_image">
  77. <el-image
  78. v-if="item.platformIcon"
  79. style="width: 100%; height: 100%"
  80. :src="item.platformIcon"
  81. fit="cover"
  82. ></el-image>
  83. <span v-else>-</span>
  84. </div>
  85. </div>
  86. <div>
  87. <span>默认图标:</span>
  88. <div class="ui_m_image">
  89. <el-image
  90. v-if="item.defaultIcon"
  91. style="width: 100%; height: 100%"
  92. :src="item.defaultIcon"
  93. fit="cover"
  94. ></el-image>
  95. <span v-else>-</span>
  96. </div>
  97. </div>
  98. <div>
  99. <span>激活图标:</span>
  100. <div class="ui_m_image">
  101. <el-image
  102. v-if="item.activeIcon"
  103. style="width: 100%; height: 100%"
  104. :src="item.activeIcon"
  105. fit="cover"
  106. ></el-image>
  107. <span v-else>-</span>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <el-button slot="reference">查看设置</el-button>
  114. </el-popover>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="参数" min-width="150" show-overflow-tooltip>
  118. <template slot-scope="scope">
  119. <div v-if="scope.row.argumentList.length">
  120. <el-tag
  121. v-for="(item, index) in scope.row.argumentList"
  122. :key="index"
  123. style="margin-right: 10px"
  124. effect="plain"
  125. >{{ item }}</el-tag
  126. >
  127. </div>
  128. <span v-else>-</span>
  129. </template>
  130. </el-table-column>
  131. <el-table-column
  132. label="仅管理员显示"
  133. min-width="45"
  134. show-overflow-tooltip
  135. >
  136. <template slot-scope="scope">{{
  137. scope.row.isAdmin == "1" ? "是" : "否"
  138. }}</template>
  139. </el-table-column>
  140. <el-table-column label="工具状态" min-width="50" show-overflow-tooltip>
  141. <template slot-scope="scope">{{
  142. statusList[scope.row.status]
  143. }}</template>
  144. </el-table-column>
  145. <el-table-column label="操作" width="200px" show-overflow-tooltip>
  146. <template slot-scope="scope">
  147. <button
  148. @click="editTool(scope.row)"
  149. style="
  150. color: #308fff;
  151. background: none;
  152. border: none;
  153. cursor: pointer;
  154. margin-left: 25px;
  155. "
  156. >
  157. 修改
  158. </button>
  159. <button
  160. v-if="scope.row.status == '0'"
  161. @click="changeToolStatus(scope.row, '1')"
  162. style="
  163. color: #ff2570;
  164. background: none;
  165. border: none;
  166. cursor: pointer;
  167. margin-left: 25px;
  168. "
  169. >
  170. 停用
  171. </button>
  172. <button
  173. v-if="scope.row.status == '1'"
  174. @click="changeToolStatus(scope.row, '0')"
  175. style="
  176. color: #67C23A;
  177. background: none;
  178. border: none;
  179. cursor: pointer;
  180. margin-left: 25px;
  181. "
  182. >
  183. 启用
  184. </button>
  185. </template>
  186. </el-table-column>
  187. </el-table>
  188. <el-pagination
  189. style="margin-top: 10px"
  190. :current-page="pageData.nowPage"
  191. :page-size="pageData.lim"
  192. :total="pageData.total"
  193. @current-change="handlePageChange"
  194. layout="total,prev, pager, next, jumper"
  195. >
  196. </el-pagination>
  197. </div>
  198. <addDesktopToolDialog
  199. ref="addDesktopToolDialogRef"
  200. @success="addDesktopToolSuccess"
  201. />
  202. </div>
  203. </template>
  204. <script>
  205. import { API_CONFIG } from "@/common/apiConfig";
  206. import addDesktopToolDialog from "./dialog/addDesktopToolDialog.vue";
  207. export default {
  208. components: {
  209. addDesktopToolDialog,
  210. },
  211. data() {
  212. return {
  213. desktopList: [],
  214. selectStatus: "",
  215. pageData: {
  216. nowPage: 1,
  217. lim: 10,
  218. total: 0,
  219. },
  220. loading: false,
  221. statusList: ["正常使用", "已停用", "已删除"],
  222. };
  223. },
  224. methods: {
  225. // 表头的背景色
  226. headerCellStyle() {
  227. return { backgroundColor: "#f1f1f1" };
  228. },
  229. //获取数据
  230. getData() {
  231. let params = [
  232. {
  233. functionName: "select_desktopToolByPage",
  234. status: this.selectStatus,
  235. page: this.pageData.nowPage,
  236. lim: this.pageData.lim,
  237. },
  238. ];
  239. this.loading = true;
  240. this.$ajax
  241. .post(API_CONFIG.baseUrl, params)
  242. .then((res) => {
  243. let _data = res.data;
  244. let _list = _data[0];
  245. let _total = _data[1][0].total;
  246. _list.forEach((i) => {
  247. i.url = JSON.parse(i.url);
  248. i.json = JSON.parse(i.json);
  249. i.argumentList = JSON.parse(i.argumentList);
  250. });
  251. this.desktopList = _list;
  252. this.pageData.total = _total;
  253. this.loading = false;
  254. // console.log(_data)
  255. })
  256. .catch((err) => {
  257. console.log(err);
  258. this.loading = false;
  259. this.$message.error("获取工具数据失败");
  260. });
  261. },
  262. handlePageChange(newPage) {
  263. this.pageData.nowPage = newPage;
  264. this.getData();
  265. },
  266. addTool() {
  267. this.$refs.addDesktopToolDialogRef.open();
  268. },
  269. addDesktopToolSuccess(form) {
  270. if (form.id) {
  271. let params = [
  272. {
  273. functionName: "update_desktopToolById",
  274. id: form.id,
  275. toolId:form.toolId,
  276. width: form.dialogWidth,
  277. height: form.dialogHeight,
  278. description: form.description,
  279. admin: form.isAdmin,
  280. argumentList: JSON.stringify(form.argumentList),
  281. url: JSON.stringify(form.url),
  282. json: JSON.stringify(form.json),
  283. status: form.status,
  284. },
  285. ];
  286. this.$refs.addDesktopToolDialogRef.loading = true;
  287. this.$ajax
  288. .post(API_CONFIG.baseUrl, params)
  289. .then((res) => {
  290. if (res.data == 1) {
  291. this.$refs.addDesktopToolDialogRef.close();
  292. this.$message.success("修改工具成功");
  293. } else if(res.data[0][0].message == "repeat toolId"){
  294. this.$message.error("工具标识重复!")
  295. } else {
  296. this.$message.error("修改工具失败");
  297. }
  298. this.$refs.addDesktopToolDialogRef.loading = false;
  299. this.getData();
  300. })
  301. .catch((err) => {
  302. console.log(err);
  303. this.$message.error("修改工具失败");
  304. this.$refs.addDesktopToolDialogRef.loading = false;
  305. });
  306. } else {
  307. let params = [
  308. {
  309. functionName: "insert_desktopTool",
  310. toolId:form.toolId,
  311. width: form.dialogWidth,
  312. height: form.dialogHeight,
  313. description: form.description,
  314. admin: form.isAdmin,
  315. argumentList: JSON.stringify(form.argumentList),
  316. url: JSON.stringify(form.url),
  317. json: JSON.stringify(form.json),
  318. },
  319. ];
  320. this.$refs.addDesktopToolDialogRef.loading = true;
  321. this.$ajax
  322. .post(API_CONFIG.baseUrl, params)
  323. .then((res) => {
  324. console.log(res)
  325. if (res.data == 1) {
  326. this.$refs.addDesktopToolDialogRef.close();
  327. this.$message.success("添加工具成功");
  328. } else if(res.data[0][0].message == "repeat toolId"){
  329. this.$message.error("工具标识重复!")
  330. }else{
  331. this.$message.error("添加工具失败");
  332. }
  333. this.$refs.addDesktopToolDialogRef.loading = false;
  334. this.getData();
  335. })
  336. .catch((err) => {
  337. console.log(err);
  338. this.$message.error("添加工具失败");
  339. this.$refs.addDesktopToolDialogRef.loading = false;
  340. });
  341. }
  342. },
  343. editTool(item) {
  344. this.$refs.addDesktopToolDialogRef.open(item);
  345. },
  346. changeStatus() {
  347. this.pageData.nowPage = 1;
  348. this.getData();
  349. },
  350. changeToolStatus(item, newValue) {
  351. let _data = JSON.parse(JSON.stringify(item));
  352. _data.status = newValue;
  353. this.loading = true;
  354. let params = [
  355. {
  356. functionName: "update_desktopToolById",
  357. id: _data.id,
  358. toolId:_data.toolId,
  359. width: _data.dialogWidth,
  360. height: _data.dialogHeight,
  361. description: _data.description,
  362. admin: _data.isAdmin,
  363. argumentList: JSON.stringify(_data.argumentList),
  364. url: JSON.stringify(_data.url),
  365. json: JSON.stringify(_data.json),
  366. status: _data.status,
  367. },
  368. ];
  369. this.$ajax
  370. .post(API_CONFIG.baseUrl, params)
  371. .then((res) => {
  372. if (res.data == 1) {
  373. this.$message.success("已停用");
  374. } else {
  375. this.$message.error("停用失败");
  376. }
  377. this.loading = false;
  378. this.getData();
  379. })
  380. .catch((err) => {
  381. console.log(err);
  382. this.loading = false;
  383. this.$message.error("停用失败");
  384. });
  385. },
  386. },
  387. mounted() {
  388. this.getData();
  389. },
  390. };
  391. </script>
  392. <style scoped>
  393. .desktopToolList {
  394. width: 100%;
  395. height: 100%;
  396. box-sizing: border-box;
  397. padding: 10px;
  398. overflow: auto;
  399. }
  400. .tableArea {
  401. margin: 10px 0;
  402. }
  403. .button_top {
  404. width: 100%;
  405. display: flex;
  406. align-items: center;
  407. margin: 10px 0;
  408. }
  409. .button_top > div {
  410. font-weight: bold;
  411. margin-right: 20px;
  412. cursor: pointer;
  413. }
  414. .title_examine {
  415. display: flex;
  416. justify-content: space-between;
  417. }
  418. .urlItemBox {
  419. display: flex;
  420. flex-wrap: wrap;
  421. }
  422. .urlItem {
  423. width: 400px;
  424. height: 250px;
  425. overflow: auto;
  426. position: relative;
  427. box-sizing: border-box;
  428. border-bottom: solid 1px #ebeef5;
  429. }
  430. /* .urlItem::after{
  431. content: "";
  432. height: 2px;
  433. width: 100%;
  434. background-color: #ebeef5;
  435. position: absolute;
  436. bottom: 10px;
  437. } */
  438. .urlItem:nth-child(2n) {
  439. margin-left: 20px;
  440. }
  441. .urlItem > span {
  442. font-size: 18px;
  443. font-weight: bold;
  444. }
  445. .ui_m_image {
  446. width: 40px;
  447. height: 40px;
  448. float: left;
  449. display: flex;
  450. align-items: center;
  451. }
  452. .ui_message > div {
  453. display: flex;
  454. align-items: center;
  455. }
  456. .ui_message > div > span {
  457. white-space: nowrap;
  458. }
  459. </style>