|
@@ -0,0 +1,208 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <van-nav-bar title="项目管理" left-text="返回" @click-left="back" right-text="新增项目" @click-right="openDialog(-1)" fixed left-arrow/>
|
|
|
+
|
|
|
+ <div class="login_form">
|
|
|
+ <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
|
|
+ <van-list v-model="loading" :finished="finished" finished-text="没有更多了" :error.sync="error" error-text="请求失败,点击重新加载" @load="getProject">
|
|
|
+ <van-swipe-cell v-for="(item,index) in list" :key="index">
|
|
|
+ <van-cell :border="false" :title="item.projectName"/>
|
|
|
+ <template slot="right">
|
|
|
+ <van-button square type="info" text="编辑" @click="openDialog(index)"/>
|
|
|
+ <van-button square type="danger" text="删除" @click="delPro(index)"/>
|
|
|
+ </template>
|
|
|
+ </van-swipe-cell>
|
|
|
+ </van-list>
|
|
|
+ </van-pull-refresh>
|
|
|
+
|
|
|
+ <van-dialog v-model="show" :title="title" show-cancel-button :beforeClose="chargeBtn">
|
|
|
+ <van-form style="margin: 0.4rem 0;">
|
|
|
+ <van-field v-model="form.projectName" name="项目名称" label="项目名称" placeholder="请填写项目名称" :rules="[{ required: true, message: '请填写项目名称' }]"/>
|
|
|
+ </van-form>
|
|
|
+ </van-dialog>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ user: JSON.parse(sessionStorage.userInfo),
|
|
|
+
|
|
|
+ total: 0,
|
|
|
+ page: 1,
|
|
|
+ size: 20,
|
|
|
+ list: [],
|
|
|
+ loading: false,
|
|
|
+ finished: false,
|
|
|
+ error: false,
|
|
|
+ refreshing: false,
|
|
|
+
|
|
|
+ show: false,
|
|
|
+ title: "标题",
|
|
|
+ form: {
|
|
|
+ id: null,
|
|
|
+ projectName: "",
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 返回
|
|
|
+ back() {
|
|
|
+ history.back();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取项目
|
|
|
+ getProject() {
|
|
|
+ if (this.refreshing) {
|
|
|
+ this.list = [];
|
|
|
+ this.refreshing = false;
|
|
|
+ }
|
|
|
+ if(this.total == this.list.length && this.list.length != 0) {
|
|
|
+ this.loading = false;
|
|
|
+ this.finished = true;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ this.$axios.post("/project/getProjectPage", {
|
|
|
+ pageIndex: this.page,
|
|
|
+ pageSize: this.size,
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ if(res.code == "ok") {
|
|
|
+ this.loading = false;
|
|
|
+ for(var i in res.data.records) {
|
|
|
+ this.list.push(res.data.records[i])
|
|
|
+ }
|
|
|
+ this.total = res.data.total;
|
|
|
+ } else {
|
|
|
+ this.$toast.fail('获取失败');
|
|
|
+ }
|
|
|
+ }).catch(err=> {toast.clear();});
|
|
|
+ },
|
|
|
+
|
|
|
+ onRefresh() {
|
|
|
+ this.finished = false;
|
|
|
+ this.loading = true;
|
|
|
+ this.page = 1;
|
|
|
+ this.getProject();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 新增、编辑项目
|
|
|
+ openDialog(i) {
|
|
|
+ if(i == -1) {
|
|
|
+ this.form = {
|
|
|
+ id: null,
|
|
|
+ projectName: "",
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.form = {
|
|
|
+ id: this.list[i].id,
|
|
|
+ projectName: this.list[i].projectName,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.show = true;
|
|
|
+ },
|
|
|
+
|
|
|
+ chargeBtn(action, done) {
|
|
|
+ if (action === 'confirm') {
|
|
|
+ this.show = false;
|
|
|
+ const toast = this.$toast.loading({
|
|
|
+ forbidClick: true,
|
|
|
+ duration: 0
|
|
|
+ });
|
|
|
+ let form = {
|
|
|
+ name: this.form.projectName
|
|
|
+ }
|
|
|
+ if(this.form.id != null) {
|
|
|
+ form.id = this.form.id;
|
|
|
+ }
|
|
|
+ this.$axios.post("/project/editProject", form)
|
|
|
+ .then(res => {
|
|
|
+ if(res.code == "ok") {
|
|
|
+ toast.clear();
|
|
|
+ this.$toast.success(this.form.id==null?'新增成功':'修改成功');
|
|
|
+ this.list = [];
|
|
|
+ this.page = 1;
|
|
|
+ this.getProject();
|
|
|
+ } else {
|
|
|
+ toast.clear();
|
|
|
+ this.$toast.fail(this.form.id==null?'新增失败':'修改失败');
|
|
|
+ }
|
|
|
+ }).catch(err=> {toast.clear();});
|
|
|
+ } else {
|
|
|
+ this.show = false;
|
|
|
+ }
|
|
|
+ done();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 删除项目
|
|
|
+ delPro(i) {
|
|
|
+ this.$dialog.confirm({
|
|
|
+ title: '删除项目',
|
|
|
+ message: '确定要项目'+this.list[i].projectName+'吗?'
|
|
|
+ }).then(() => {
|
|
|
+ const toast = this.$toast.loading({
|
|
|
+ forbidClick: true,
|
|
|
+ duration: 0
|
|
|
+ });
|
|
|
+ this.$axios.post("/project/deleteProject", {id: this.list[i].id})
|
|
|
+ .then(res => {
|
|
|
+ if(res.code == "ok") {
|
|
|
+ toast.clear();
|
|
|
+ this.$toast.success('删除成功');
|
|
|
+ this.list = [];
|
|
|
+ this.page = 1;
|
|
|
+ this.getProject();
|
|
|
+ } else {
|
|
|
+ toast.clear();
|
|
|
+ this.$toast.fail('删除失败');
|
|
|
+ }
|
|
|
+ }).catch(err=> {toast.clear();});
|
|
|
+ }).catch(() => {});
|
|
|
+ },
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ mounted() {
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+ .login_form {
|
|
|
+ margin-top: 46px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .one_report {
|
|
|
+ margin-bottom: 15px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .form_text {
|
|
|
+ margin: 15px 0 30px;
|
|
|
+ padding: 0 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .form_btn {
|
|
|
+ text-align: right;
|
|
|
+ }
|
|
|
+
|
|
|
+ .form_btn button {
|
|
|
+ margin-left: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .one_report_data {
|
|
|
+ margin-bottom: 20px;
|
|
|
+ padding: 0 22px;
|
|
|
+ div {
|
|
|
+ line-height: 30px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|
|
|
+<style lang="less">
|
|
|
+ .van-nav-bar .van-icon , .van-nav-bar__text {
|
|
|
+ color: #20a0ff;
|
|
|
+ }
|
|
|
+</style>
|