| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 |
- <template>
- <div class="desktopToolList">
- <div class="title_examine">
- <div class="pub_title">工具列表</div>
- <div class="t_right">
- <el-button type="primary" size="small" @click="addTool()"
- >添加工具</el-button
- >
- </div>
- </div>
- <div class="table_content tableArea">
- <div class="button_top">
- <div @click="changeStatus('')">全部({{ pageData.total }})</div>
- </div>
- <el-table
- :data="desktopList"
- stripe
- border
- style="width: 100%"
- v-loading="loading"
- :header-cell-style="headerCellStyle"
- >
- <el-table-column label="标识" min-width="45" show-overflow-tooltip>
- <template slot-scope="scope">{{
- scope.row.toolId ? scope.row.toolId : "-"
- }}</template>
- </el-table-column>
- <el-table-column label="宽度" min-width="45" show-overflow-tooltip>
- <template slot-scope="scope">{{
- scope.row.dialogWidth ? scope.row.dialogWidth : "-"
- }}</template>
- </el-table-column>
- <el-table-column label="高度" min-width="45" show-overflow-tooltip>
- <template slot-scope="scope">{{
- scope.row.dialogHeight ? scope.row.dialogHeight : "-"
- }}</template>
- </el-table-column>
- <el-table-column label="描述" min-width="200" show-overflow-tooltip>
- <template slot-scope="scope">{{
- scope.row.description ? scope.row.description : "-"
- }}</template>
- </el-table-column>
- <el-table-column label="工具设置" min-width="45" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-popover placement="bottom" width="840" trigger="hover">
- <div class="urlItemBox">
- <div
- class="urlItem"
- v-for="(item, index) in scope.row.url"
- :key="scope.row.id + '-' + index"
- >
- <span>{{ item.region }}</span>
- <div class="ui_message">
- <div>名称:{{ item.name ? item.name : "-" }}</div>
- <div>
- <span>链接:</span
- ><a :href="item.url" v-if="item.url" target="_blank">{{
- item.url
- }}</a
- ><span v-else>-</span>
- </div>
- <div>
- <span>桌面图标:</span>
- <div class="ui_m_image">
- <el-image
- v-if="item.icon"
- style="width: 100%; height: 100%"
- :src="item.icon"
- fit="cover"
- ></el-image>
- <span v-else>-</span>
- </div>
- </div>
- <div>
- <span>平台图标:</span>
- <div class="ui_m_image">
- <el-image
- v-if="item.platformIcon"
- style="width: 100%; height: 100%"
- :src="item.platformIcon"
- fit="cover"
- ></el-image>
- <span v-else>-</span>
- </div>
- </div>
- <div>
- <span>默认图标:</span>
- <div class="ui_m_image">
- <el-image
- v-if="item.defaultIcon"
- style="width: 100%; height: 100%"
- :src="item.defaultIcon"
- fit="cover"
- ></el-image>
- <span v-else>-</span>
- </div>
- </div>
- <div>
- <span>激活图标:</span>
- <div class="ui_m_image">
- <el-image
- v-if="item.activeIcon"
- style="width: 100%; height: 100%"
- :src="item.activeIcon"
- fit="cover"
- ></el-image>
- <span v-else>-</span>
- </div>
- </div>
- </div>
- </div>
- </div>
- <el-button slot="reference">查看设置</el-button>
- </el-popover>
- </template>
- </el-table-column>
- <el-table-column label="参数" min-width="150" show-overflow-tooltip>
- <template slot-scope="scope">
- <div v-if="scope.row.argumentList.length">
- <el-tag
- v-for="(item, index) in scope.row.argumentList"
- :key="index"
- style="margin-right: 10px"
- effect="plain"
- >{{ item }}</el-tag
- >
- </div>
- <span v-else>-</span>
- </template>
- </el-table-column>
- <el-table-column
- label="仅管理员显示"
- min-width="45"
- show-overflow-tooltip
- >
- <template slot-scope="scope">{{
- scope.row.isAdmin == "1" ? "是" : "否"
- }}</template>
- </el-table-column>
- <el-table-column label="工具状态" min-width="50" show-overflow-tooltip>
- <template slot-scope="scope">{{
- statusList[scope.row.status]
- }}</template>
- </el-table-column>
- <el-table-column label="操作" width="200px" show-overflow-tooltip>
- <template slot-scope="scope">
- <button
- @click="editTool(scope.row)"
- style="
- color: #308fff;
- background: none;
- border: none;
- cursor: pointer;
- margin-left: 25px;
- "
- >
- 修改
- </button>
- <button
- v-if="scope.row.status == '0'"
- @click="changeToolStatus(scope.row, '1')"
- style="
- color: #ff2570;
- background: none;
- border: none;
- cursor: pointer;
- margin-left: 25px;
- "
- >
- 停用
- </button>
- <button
- v-if="scope.row.status == '1'"
- @click="changeToolStatus(scope.row, '0')"
- style="
- color: #67C23A;
- background: none;
- border: none;
- cursor: pointer;
- margin-left: 25px;
- "
- >
- 启用
- </button>
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- style="margin-top: 10px"
- :current-page="pageData.nowPage"
- :page-size="pageData.lim"
- :total="pageData.total"
- @current-change="handlePageChange"
- layout="total,prev, pager, next, jumper"
- >
- </el-pagination>
- </div>
- <addDesktopToolDialog
- ref="addDesktopToolDialogRef"
- @success="addDesktopToolSuccess"
- />
- </div>
- </template>
- <script>
- import { API_CONFIG } from "@/common/apiConfig";
- import addDesktopToolDialog from "./dialog/addDesktopToolDialog.vue";
- export default {
- components: {
- addDesktopToolDialog,
- },
- data() {
- return {
- desktopList: [],
- selectStatus: "",
- pageData: {
- nowPage: 1,
- lim: 10,
- total: 0,
- },
- loading: false,
- statusList: ["正常使用", "已停用", "已删除"],
- };
- },
- methods: {
- // 表头的背景色
- headerCellStyle() {
- return { backgroundColor: "#f1f1f1" };
- },
- //获取数据
- getData() {
- let params = [
- {
- functionName: "select_desktopToolByPage",
- status: this.selectStatus,
- page: this.pageData.nowPage,
- lim: this.pageData.lim,
- },
- ];
- this.loading = true;
- this.$ajax
- .post(API_CONFIG.baseUrl, params)
- .then((res) => {
- let _data = res.data;
- let _list = _data[0];
- let _total = _data[1][0].total;
- _list.forEach((i) => {
- i.url = JSON.parse(i.url);
- i.json = JSON.parse(i.json);
- i.argumentList = JSON.parse(i.argumentList);
- });
- this.desktopList = _list;
- this.pageData.total = _total;
- this.loading = false;
- // console.log(_data)
- })
- .catch((err) => {
- console.log(err);
- this.loading = false;
- this.$message.error("获取工具数据失败");
- });
- },
- handlePageChange(newPage) {
- this.pageData.nowPage = newPage;
- this.getData();
- },
- addTool() {
- this.$refs.addDesktopToolDialogRef.open();
- },
- addDesktopToolSuccess(form) {
- if (form.id) {
- let params = [
- {
- functionName: "update_desktopToolById",
- id: form.id,
- toolId:form.toolId,
- width: form.dialogWidth,
- height: form.dialogHeight,
- description: form.description,
- admin: form.isAdmin,
- argumentList: JSON.stringify(form.argumentList),
- url: JSON.stringify(form.url),
- json: JSON.stringify(form.json),
- status: form.status,
- },
- ];
- this.$refs.addDesktopToolDialogRef.loading = true;
- this.$ajax
- .post(API_CONFIG.baseUrl, params)
- .then((res) => {
- if (res.data == 1) {
- this.$refs.addDesktopToolDialogRef.close();
- this.$message.success("修改工具成功");
- } else if(res.data[0][0].message == "repeat toolId"){
- this.$message.error("工具标识重复!")
- } else {
- this.$message.error("修改工具失败");
- }
- this.$refs.addDesktopToolDialogRef.loading = false;
- this.getData();
- })
- .catch((err) => {
- console.log(err);
- this.$message.error("修改工具失败");
- this.$refs.addDesktopToolDialogRef.loading = false;
- });
- } else {
- let params = [
- {
- functionName: "insert_desktopTool",
- toolId:form.toolId,
- width: form.dialogWidth,
- height: form.dialogHeight,
- description: form.description,
- admin: form.isAdmin,
- argumentList: JSON.stringify(form.argumentList),
- url: JSON.stringify(form.url),
- json: JSON.stringify(form.json),
- },
- ];
- this.$refs.addDesktopToolDialogRef.loading = true;
- this.$ajax
- .post(API_CONFIG.baseUrl, params)
- .then((res) => {
- console.log(res)
- if (res.data == 1) {
- this.$refs.addDesktopToolDialogRef.close();
- this.$message.success("添加工具成功");
- } else if(res.data[0][0].message == "repeat toolId"){
- this.$message.error("工具标识重复!")
- }else{
- this.$message.error("添加工具失败");
- }
- this.$refs.addDesktopToolDialogRef.loading = false;
- this.getData();
- })
- .catch((err) => {
- console.log(err);
- this.$message.error("添加工具失败");
- this.$refs.addDesktopToolDialogRef.loading = false;
- });
- }
- },
- editTool(item) {
- this.$refs.addDesktopToolDialogRef.open(item);
- },
- changeStatus() {
- this.pageData.nowPage = 1;
- this.getData();
- },
- changeToolStatus(item, newValue) {
- let _data = JSON.parse(JSON.stringify(item));
- _data.status = newValue;
- this.loading = true;
- let params = [
- {
- functionName: "update_desktopToolById",
- id: _data.id,
- toolId:_data.toolId,
- width: _data.dialogWidth,
- height: _data.dialogHeight,
- description: _data.description,
- admin: _data.isAdmin,
- argumentList: JSON.stringify(_data.argumentList),
- url: JSON.stringify(_data.url),
- json: JSON.stringify(_data.json),
- status: _data.status,
- },
- ];
- this.$ajax
- .post(API_CONFIG.baseUrl, params)
- .then((res) => {
- if (res.data == 1) {
- this.$message.success("已停用");
- } else {
- this.$message.error("停用失败");
- }
- this.loading = false;
- this.getData();
- })
- .catch((err) => {
- console.log(err);
- this.loading = false;
- this.$message.error("停用失败");
- });
- },
- },
- mounted() {
- this.getData();
- },
- };
- </script>
- <style scoped>
- .desktopToolList {
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- padding: 10px;
- overflow: auto;
- }
- .tableArea {
- margin: 10px 0;
- }
- .button_top {
- width: 100%;
- display: flex;
- align-items: center;
- margin: 10px 0;
- }
- .button_top > div {
- font-weight: bold;
- margin-right: 20px;
- cursor: pointer;
- }
- .title_examine {
- display: flex;
- justify-content: space-between;
- }
- .urlItemBox {
- display: flex;
- flex-wrap: wrap;
- }
- .urlItem {
- width: 400px;
- height: 250px;
- overflow: auto;
- position: relative;
- box-sizing: border-box;
- border-bottom: solid 1px #ebeef5;
- }
- /* .urlItem::after{
- content: "";
- height: 2px;
- width: 100%;
- background-color: #ebeef5;
- position: absolute;
- bottom: 10px;
- } */
- .urlItem:nth-child(2n) {
- margin-left: 20px;
- }
- .urlItem > span {
- font-size: 18px;
- font-weight: bold;
- }
- .ui_m_image {
- width: 40px;
- height: 40px;
- float: left;
- display: flex;
- align-items: center;
- }
- .ui_message > div {
- display: flex;
- align-items: center;
- }
- .ui_message > div > span {
- white-space: nowrap;
- }
- </style>
|