加了接口

main
cc 2024-03-22 13:56:20 +00:00
parent a12f1eaa50
commit a627ebdc19
4 changed files with 347 additions and 26 deletions

167
package-lock.json generated
View File

@ -8,6 +8,8 @@
"name": "inncom_list",
"version": "0.0.0",
"dependencies": {
"axios": "^1.6.8",
"bcryptjs": "^2.4.3",
"element-plus": "^2.6.1",
"pinia": "^2.1.7",
"vue": "^3.4.21",
@ -853,6 +855,26 @@
"resolved": "https://registry.npmjs.org/async-validator/-/async-validator-4.2.5.tgz",
"integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg=="
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/axios": {
"version": "1.6.8",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz",
"integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/bcryptjs": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
"integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ=="
},
"node_modules/binary-extensions": {
"version": "2.3.0",
"resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.3.0.tgz",
@ -895,6 +917,17 @@
"fsevents": "~2.3.2"
}
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dependencies": {
"delayed-stream": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/csstype": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
@ -905,6 +938,14 @@
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz",
"integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ=="
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/element-plus": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.6.1.tgz",
@ -1001,6 +1042,38 @@
"node": ">=8"
}
},
"node_modules/follow-redirects": {
"version": "1.15.6",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
@ -1111,6 +1184,25 @@
"resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-6.0.0.tgz",
"integrity": "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw=="
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/nanoid": {
"version": "3.3.7",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
@ -1233,6 +1325,11 @@
"node": "^10 || ^12 || >=14"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/readdirp": {
"version": "3.6.0",
"resolved": "https://registry.npmmirror.com/readdirp/-/readdirp-3.6.0.tgz",
@ -1279,7 +1376,7 @@
},
"node_modules/sass": {
"version": "1.72.0",
"resolved": "https://registry.npmmirror.com/sass/-/sass-1.72.0.tgz",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.72.0.tgz",
"integrity": "sha512-Gpczt3WA56Ly0Mn8Sl21Vj94s1axi9hDIzDFn9Ph9x3C3p4nNyvsqJoQyVXKou6cBlfFWEgRW4rT8Tb4i3XnVA==",
"dev": true,
"dependencies": {
@ -1883,6 +1980,26 @@
"resolved": "https://registry.npmjs.org/async-validator/-/async-validator-4.2.5.tgz",
"integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg=="
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"axios": {
"version": "1.6.8",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz",
"integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==",
"requires": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"bcryptjs": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
"integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ=="
},
"binary-extensions": {
"version": "2.3.0",
"resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.3.0.tgz",
@ -1914,6 +2031,14 @@
"readdirp": "~3.6.0"
}
},
"combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"requires": {
"delayed-stream": "~1.0.0"
}
},
"csstype": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
@ -1924,6 +2049,11 @@
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz",
"integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ=="
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
},
"element-plus": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.6.1.tgz",
@ -2001,6 +2131,21 @@
"to-regex-range": "^5.0.1"
}
},
"follow-redirects": {
"version": "1.15.6",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA=="
},
"form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
},
"fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
@ -2082,6 +2227,19 @@
"resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-6.0.0.tgz",
"integrity": "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw=="
},
"mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="
},
"mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"requires": {
"mime-db": "1.52.0"
}
},
"nanoid": {
"version": "3.3.7",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
@ -2136,6 +2294,11 @@
"source-map-js": "^1.1.0"
}
},
"proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"readdirp": {
"version": "3.6.0",
"resolved": "https://registry.npmmirror.com/readdirp/-/readdirp-3.6.0.tgz",
@ -2170,7 +2333,7 @@
},
"sass": {
"version": "1.72.0",
"resolved": "https://registry.npmmirror.com/sass/-/sass-1.72.0.tgz",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.72.0.tgz",
"integrity": "sha512-Gpczt3WA56Ly0Mn8Sl21Vj94s1axi9hDIzDFn9Ph9x3C3p4nNyvsqJoQyVXKou6cBlfFWEgRW4rT8Tb4i3XnVA==",
"dev": true,
"requires": {

View File

@ -9,6 +9,8 @@
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.6.8",
"bcryptjs": "^2.4.3",
"element-plus": "^2.6.1",
"pinia": "^2.1.7",
"vue": "^3.4.21",

0
src/api/api.js Normal file
View File

View File

@ -3,54 +3,210 @@
<el-row>
<el-col :span="6">
<el-card>
<el-button :icon="Plus" circle @click="new_project.name = ''; new_project.description = ''; add_project_enable = true;" />
<el-button :icon="Plus" circle @click="
add_project_info.name = '';
add_project_info.description = '';
add_project_info.enable = true;
" />
</el-card>
</el-col>
<el-col :span="6" v-for="(item,index) in project_data.list" :key="index">
<el-col :span="6" v-for="(item, index) in projects" :key="index">
<el-card>
<p>{{ item.name }}</p>
<p>{{ item.description }}</p>
<p>{{ item.content }}</p>
<el-button type="primary" round>管理</el-button>
<el-button type="success" round @click="
update_project_info.name = item.name;
update_project_info.new_name = item.name;
update_project_info.description = item.description;
update_project_info.content = item.content || null;
update_project_info.enable = true;
">编辑</el-button>
<el-button type="danger" round @click="remove_project(item)"></el-button>
</el-card>
</el-col>
</el-row>
</el-card>
<el-dialog v-model="add_project_enable" title="新增项目" width="500">
<el-form :model="new_project">
<el-dialog v-model="add_project_info.enable" title="新增项目" width="500">
<el-form :model="add_project_info">
<el-form-item label="项目名称">
<el-input v-model="new_project.name" />
<el-input v-model="add_project_info.name" />
</el-form-item>
<el-form-item label="项目描述">
<el-input v-model="new_project.description" type="textarea" />
<el-input v-model="add_project_info.description" type="textarea" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="add_project"></el-button>
<el-button @click="add_project_enable = false">取消</el-button>
<el-button @click="add_project_info.enable = false">取消</el-button>
</el-form-item>
</el-form>
</el-dialog>
<el-dialog v-model="update_project_info.enable" title="修改项目" width="500">
<el-form :model="update_project_info">
<el-form-item label="项目名称">
<el-input v-model="update_project_info.name" disabled />
</el-form-item>
<el-form-item label="项目名称">
<el-input v-model="update_project_info.new_name" />
</el-form-item>
<el-form-item label="项目描述">
<el-input v-model="update_project_info.description" type="textarea" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="update_project"></el-button>
<el-button @click="update_project_info.enable = false">取消</el-button>
</el-form-item>
</el-form>
</el-dialog>
</template>
<script setup>
import { Plus } from '@element-plus/icons-vue'
import { ref, reactive } from 'vue'
import { usrProjectStore } from '../store/project'
import { Plus } from "@element-plus/icons-vue";
import { ref, reactive } from "vue";
import { ElMessage } from "element-plus";
import { onMounted } from "vue";
import axios from "axios";
axios.defaults.headers = {
name: "cc",
token: "",
};
const project_data = usrProjectStore();
const add_project_enable = ref(false);
const new_project = reactive({
name: '',
description: '',
});
const add_project = () => {
project_data.list.push({
name: new_project.name,
description: new_project.description,
const projects = ref();
const get_projects = () => {
axios({
method: "post",
url: "http://10.10.10.4:3000/api/honeywell/inncon/list/project",
data: {
action: 100,
},
}).then((response) => {
var data = response.data;
if (data.code === 0) {
projects.value = data.data;
} else {
ElMessage({
message: data.message,
type: "warning",
});
}
}).catch((error) => {
ElMessage({
message: error,
type: "warning",
});
});
};
const add_project_info = reactive({
enable: false,
name: "",
description: "",
});
const add_project = () => {
axios({
method: "post",
url: "http://10.10.10.4:3000/api/honeywell/inncon/list/project",
data: {
action: 101,
data: add_project_info,
},
}).then((response) => {
var data = response.data;
if (data.code === 0) {
ElMessage({
message: "新增成功",
type: "success",
});
get_projects();
add_project_info.enable = false;
} else {
ElMessage({
message: data.message+'['+data.data+']',
type: "warning",
});
}
}).catch((error) => {
ElMessage({
message: error,
type: "warning",
});
});
};
const update_project_info = reactive({
enable: false,
name: "",
new_name: "",
description: "",
content: null,
});
const update_project = () => {
axios({
method: "post",
url: "http://10.10.10.4:3000/api/honeywell/inncon/list/project",
data: {
action: 102,
data: update_project_info,
},
}).then((response) => {
var data = response.data;
if (data.code === 0) {
ElMessage({
message: "更新成功",
type: "success",
});
get_projects();
update_project_info.enable = false;
} else {
ElMessage({
message: data.message+'['+data.data+']',
type: "warning",
});
}
}).catch((error) => {
ElMessage({
message: error,
type: "warning",
});
});
add_project_enable.value = false;
}
const remove_project = (item) => {
const remove_project = (project) => {
axios({
method: "post",
url: "http://10.10.10.4:3000/api/honeywell/inncon/list/project",
data: {
action: 103,
data: {
name: project.name
},
},
}).then((response) => {
var data = response.data;
if (data.code === 0) {
ElMessage({
message: "删除成功",
type: "success",
});
get_projects();
} else {
ElMessage({
message: data.message+'['+data.data+']',
type: "warning",
});
}
}).catch((error) => {
ElMessage({
message: error,
type: "warning",
});
});
};
}
onMounted(() => {
get_projects();
});
</script>