| | |
| | | <script setup name="UserManage"> |
| | | import { ref, reactive, onMounted, computed } from "vue"; |
| | | <script setup name="device"> |
| | | import { ref, reactive, onMounted, computed, nextTick } from "vue"; |
| | | import { storeToRefs } from "pinia"; |
| | | import { Search, Plus } from "@element-plus/icons-vue"; |
| | | import ycCard from "@/components/ycCard/index.vue"; |
| | |
| | | } = useStation(); |
| | | |
| | | import powerTypes from '@/utils/const/const_powerType.js'; |
| | | import { |
| | | delBatt, |
| | | getPowerBrand, |
| | | getVoltageLevel, |
| | | } from "@/api/station"; |
| | | |
| | | const userStore = useUserStore(); |
| | | const { uid, uname } = storeToRefs(userStore); |
| | | |
| | | import { |
| | | getAllUser, |
| | | deleteUser, |
| | | dropRole, |
| | | improveRole, |
| | | resetSnId, |
| | | } from "@/api/user"; |
| | | |
| | | |
| | | import { |
| | | getDevList, |
| | |
| | | width: "120", |
| | | }, |
| | | ]; |
| | | |
| | | const company = ref(""); |
| | | const companyList = ref([]); |
| | | const volLevels = ref([]); |
| | | const powerType = ref(''); |
| | | const stationType = ref(''); |
| | | const background = ref(true); |
| | | const disabled = ref(false); |
| | | const pageCurr = ref(1); |
| | |
| | | rowData: {}, |
| | | }); |
| | | |
| | | const powerTypeList = computed(() => { |
| | | return Object.keys(powerTypes).map(v => ({ label: powerTypes[v], value: v * 1 })); |
| | | }); |
| | | |
| | | // const tableData = reactive([]); |
| | | // const rowData = reactive({}); |
| | | |
| | |
| | | function getList() { |
| | | let loading = $loading(); |
| | | let params = { |
| | | // city: "", |
| | | // country: "", |
| | | provice: provice.value || undefined, |
| | | city: city.value || undefined, |
| | | country: country.value || undefined, |
| | | stationName: stationName.value || undefined, |
| | | powerType: powerType.value || undefined, |
| | | stationType: stationType.value || undefined, |
| | | pageNum: pageCurr.value, |
| | | pageSize: pageSize.value, |
| | | // powerName: "", |
| | | // provice: "", |
| | | // stationName: "", |
| | | }; |
| | | |
| | | getDevList(params) |
| | |
| | | }); |
| | | } |
| | | |
| | | function getCompanyList() { |
| | | getPowerBrand().then((res) => { |
| | | let { code, data, data2 } = res; |
| | | let list = []; |
| | | if (code && data) { |
| | | list = data2; |
| | | } |
| | | companyList.value = list; |
| | | }); |
| | | } |
| | | |
| | | // 获取电压等级 |
| | | function getVolLevels() { |
| | | console.log("获取电压等级"); |
| | | getVoltageLevel().then((res) => { |
| | | let { code, data, data2 } = res; |
| | | let list = []; |
| | | if (code && data) { |
| | | list = data2; |
| | | } |
| | | volLevels.value = list; |
| | | }); |
| | | } |
| | | |
| | | // 展示数据数量 |
| | | function handleSizeChange(val) { |
| | | pageSize.value = val; |
| | |
| | | } |
| | | function add() { |
| | | dialogTitle.value = "添加设备"; |
| | | datas.rowData = null; |
| | | datas.rowData = {}; |
| | | addEditVisible.value = true; |
| | | } |
| | | function edit(record) { |
| | |
| | | } |
| | | |
| | | function confirmRemove(record) { |
| | | $confirm("删除该用户", () => { |
| | | remove(record.name); |
| | | $confirm("删除", () => { |
| | | let { stationId, powerId, battgroupId } = record; |
| | | remove(stationId, powerId, battgroupId||undefined); |
| | | }); |
| | | } |
| | | function remove(uname) { |
| | | function remove(stationId, powerId, battgroupId) { |
| | | let loading = $loading(); |
| | | deleteUser(uname) |
| | | delBatt(stationId, powerId, battgroupId) |
| | | .then((res) => { |
| | | let { code, data } = res; |
| | | loading.close(); |
| | |
| | | function onCanel() { |
| | | addEditVisible.value = false; |
| | | } |
| | | function improveRolefn(record) { |
| | | let loading = $loading(); |
| | | improveRole(record.id) |
| | | .then((res) => { |
| | | let { code, data, msg } = res; |
| | | loading.close(); |
| | | if (code && data) { |
| | | $message.success(msg); |
| | | getList(); |
| | | } else { |
| | | $message.error(msg); |
| | | } |
| | | }) |
| | | .catch((err) => { |
| | | console.log(err); |
| | | loading.close(); |
| | | }); |
| | | } |
| | | function dropRolefn(record) { |
| | | let loading = $loading(); |
| | | dropRole(record.id) |
| | | .then((res) => { |
| | | let { code, data, msg } = res; |
| | | loading.close(); |
| | | if (code && data) { |
| | | $message.success(msg); |
| | | getList(); |
| | | } else { |
| | | $message.error(msg); |
| | | } |
| | | }) |
| | | .catch((err) => { |
| | | loading.close(); |
| | | console.log(err); |
| | | }); |
| | | } |
| | | function resetSnIdfn(record) { |
| | | $confirm("重置该用户密码", () => { |
| | | let loading = $loading(); |
| | | resetSnId(record.id).then((res) => { |
| | | let { code, data, msg } = res; |
| | | if (code && data) { |
| | | $message.success(msg); |
| | | } else { |
| | | $message.error(msg); |
| | | } |
| | | loading.close(); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | function filterChange() { |
| | | nextTick(() => { |
| | | pageCurr.value = 1; |
| | | getList(); |
| | | }); |
| | | } |
| | | |
| | | |
| | | onMounted(() => { |
| | | getCompanyList(); |
| | | getVolLevels(); |
| | | getList(); |
| | | }); |
| | | </script> |
| | |
| | | <el-select |
| | | v-model="provice" |
| | | size="small" |
| | | clearable |
| | | @change="filterChange" |
| | | placeholder="请选择省" |
| | | > |
| | | <el-option |
| | |
| | | <el-select |
| | | v-model="city" |
| | | size="small" |
| | | clearable |
| | | @change="filterChange" |
| | | placeholder="请选择市" |
| | | > |
| | | <el-option |
| | |
| | | <el-select |
| | | v-model="country" |
| | | size="small" |
| | | clearable |
| | | @change="filterChange" |
| | | placeholder="请选择区县" |
| | | > |
| | | <el-option |
| | |
| | | <el-select |
| | | v-model="stationName" |
| | | size="small" |
| | | clearable |
| | | @change="filterChange" |
| | | placeholder="请选择站点" |
| | | > |
| | | <el-option |
| | |
| | | </el-option> |
| | | </el-select> |
| | | </div> |
| | | <div class="table-cell text-right">品牌:</div> |
| | | <!-- <div class="table-cell text-right">品牌:</div> |
| | | <div class="table-cell"> |
| | | <el-select |
| | | v-model="country" |
| | | v-model="company" |
| | | size="small" |
| | | clearable |
| | | @change="filterChange" |
| | | placeholder="请选择品牌" |
| | | > |
| | | <el-option |
| | | v-for="item in countryList" |
| | | :key="item.value" |
| | | v-for="(item, idx) in companyList" |
| | | :key="'list4_' + idx" |
| | | :label="item" |
| | | :value="item" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </div> --> |
| | | <div class="table-cell text-right">电源类型:</div> |
| | | <div class="table-cell"> |
| | | <el-select |
| | | v-model="powerType" |
| | | size="small" |
| | | clearable |
| | | @change="filterChange" |
| | | placeholder="请选择品牌" |
| | | > |
| | | <el-option |
| | | v-for="(item, idx) in powerTypeList" |
| | | :key="'list4_' + idx" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | > |
| | |
| | | <div class="table-cell text-right">电压等级:</div> |
| | | <div class="table-cell"> |
| | | <el-select |
| | | v-model="country" |
| | | v-model="stationType" |
| | | size="small" |
| | | clearable |
| | | @change="filterChange" |
| | | placeholder="请选择电压等级" |
| | | > |
| | | <el-option |
| | | v-for="item in countryList" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | v-for="(item, idx) in volLevels" |
| | | :key="'list5_' + idx" |
| | | :label="item" |
| | | :value="item" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | |
| | | </el-table-column> |
| | | <el-table-column label="操作" fixed="right" width="240" align="center"> |
| | | <template #default="scope"> |
| | | <el-button type="primary" size="small" :disabled="scope.row.name == uname" |
| | | <el-button type="primary" size="small" |
| | | @click="edit(scope.row)">编辑</el-button> |
| | | <el-button type="danger" size="small" :disabled="scope.row.name == uname" |
| | | <el-button type="danger" size="small" |
| | | @click="confirmRemove(scope.row)">删除</el-button> |
| | | <el-button type="primary" size="small" :disabled="scope.row.name == uname" |
| | | <el-button type="primary" size="small" |
| | | @click="addBatt(scope.row)">添加电池组</el-button> |
| | | </template> |
| | | </el-table-column> |