wuhao 3 vuotta sitten
vanhempi
commit
7bcb64f97a

+ 86 - 82
src/views/project/list/detail.vue

@@ -21,22 +21,27 @@
           <el-table-column label="操作" align="center">
             <template slot-scope="scope">
               <!-- <el-button type="text">上架</el-button>
-              <el-button type="text">下架</el-button> -->
+              <el-button type="text">下架</el-button>-->
               <el-button type="text">发布</el-button>
               <el-button type="text" @click="getChange(scope.row)">更新</el-button>
               <el-dropdown @command="getCommand" style="margin-left: 10px">
                 <el-button type="text">更多</el-button>
                 <el-dropdown-menu slot="dropdown">
                   <el-dropdown-item command="edit">编辑</el-dropdown-item>
-                  <el-dropdown-item command="copy">复制下载地址</el-dropdown-item>
+                  <el-dropdown-item command="copy"  v-clipboard:copy="scope.row.downUrl">复制下载地址</el-dropdown-item>
                   <el-dropdown-item command="history">查看版本记录</el-dropdown-item>
                 </el-dropdown-menu>
               </el-dropdown>
             </template>
           </el-table-column>
         </el-table>
-        <pagination v-show="version_total>0" :total="version_total" :page.sync="form_version.pageNum"
-          :limit.sync="form_version.pageSize" @pagination="getPage" />
+        <pagination
+          v-show="version_total>0"
+          :total="version_total"
+          :page.sync="form_version.pageNum"
+          :limit.sync="form_version.pageSize"
+          @pagination="getPage"
+        />
       </el-form-item>
     </el-form>
     <div class="form-btn">
@@ -64,7 +69,7 @@
           <el-input v-model="formCreate.updateContent" type="textarea" rows="4" placeholder="请输入更新内容" />
         </el-form-item>
         <el-form-item label="安装包:">
-          <Upload type="file" />
+          <Upload type="file" @success="getUploadFile" />
         </el-form-item>
       </el-form>
       <div slot="footer">
@@ -133,11 +138,13 @@
 </template>
 
 <script>
-import { add, edit, update, updateAdd, updatePage } from '@/api/project/list'
-import Upload from '@/components/Upload'
+import { add, edit, update, updateAdd, updatePage } from "@/api/project/list";
+import { statusMixin } from '../mixin/index';
+import Upload from "@/components/Upload";
 export default {
+  mixins: [statusMixin],
   components: {
-    Upload
+    Upload,
   },
   data() {
     return {
@@ -147,133 +154,130 @@ export default {
       form_create: {},
       form_version: {
         pageNum: 1,
-        pageSize: 10
+        pageSize: 10,
       },
       formUpdate: {},
-      formCreate: {
-        size: 100
-      },
+      formCreate: {},
       // 列表
-      tableData_version: [{
-        name: '测试'
-      }],
+      tableData_version: [
+        {
+          name: "测试",
+        },
+      ],
       version_total: 0,
-      tableData_history: [{
-        version: 0.1
-      }],
-      statusOptions: [{
-        value: 0,
-        label: '未发布'
-      }, {
-        value: 1,
-        label: '已发布'
-      }],
-      osOptions: [{
-        value: 'IOS',
-        label: 'IOS '
-      }, {
-        value: 'Android',
-        label: 'Android'
-      }],
+      tableData_history: [
+        {
+          version: 0.1,
+        },
+      ],
+      osOptions: [
+        {
+          value: "IOS",
+          label: "IOS ",
+        },
+        {
+          value: "Android",
+          label: "Android",
+        },
+      ],
       // 弹窗
       dialogVisible_create: false,
       dialogVisible_update: false,
       dialogVisible_edit: false,
-      dialogVisible_history: false
-    }
+      dialogVisible_history: false,
+    };
   },
   mounted() {
     if (this.$route.query.row) {
-      this.form_create = this.$route.query.row
-      this.formCreate.projectId = this.form_version.projectId = this.$route.query.row.id
-      this.getPage()
+      this.form_create = this.$route.query.row;
+      this.formCreate.projectId = this.form_version.projectId =
+        this.$route.query.row.id;
+      this.getPage();
     }
   },
   methods: {
     // 更多
     getCommand(e) {
-      if (e === 'edit') {
-        this.dialogVisible_edit = true
-      } else if (e === 'copy') {
-
+      if (e === "edit") {
+        this.dialogVisible_edit = true;
+      } else if (e === "copy") {
       } else {
-        this.dialogVisible_history = true
+        this.dialogVisible_history = true;
       }
     },
 
     // 上传图标
     getUpload(e) {
-      this.form_create.pic = e
+      this.form_create.pic = e.file;
     },
 
+    // 上传logo
     getUploadCreate(e) {
-      this.formCreate.pic = e
-      console.log(this.formCreate);
+      this.formCreate.pic = e.file;
+    },
+
+    // 上传安装包
+    getUploadFile(e) {
+      this.formCreate.downUrl = e.file;
+      this.formCreate.size = e.size;
     },
 
     // 应用分页
     getPage() {
-      this.loading = true
-      updatePage(this.form_version).then(res => {
+      this.loading = true;
+      updatePage(this.form_version).then((res) => {
         if (res.code === 0) {
-          this.tableData_version = res.data.records
-          this.version_total = res.data.total
-          this.loading = false
+          this.tableData_version = res.data.records;
+          this.version_total = res.data.total;
+          this.loading = false;
         }
-      })
+      });
     },
 
     // 新增
     getAdd() {
-      updateAdd(this.formCreate).then(res => {
+      updateAdd(this.formCreate).then((res) => {
         if (res.code === 0) {
-          this.$message.success('新增成功!')
-          this.dialogVisible_create = false
-          this.getPage()
+          this.$message.success("新增成功!");
+          this.dialogVisible_create = false;
+          this.getPage();
         }
-      })
+      });
     },
 
     // 更新弹窗
     getChange(row) {
-      this.dialogVisible_update = true
-      this.formUpdate = {
-        id: row.id,
-        version: row.version,
-        updateContent: row.updateContent,
-        os: row.os,
-        name: row.name,
-        size: row.size
-      }
+      this.dialogVisible_update = true;
+      this.formUpdate = row;
     },
 
     // 更新
     getUpdate() {
-      update(this.formUpdate).then(res => {
+      update(this.formUpdate).then((res) => {
         if (res.code === 0) {
-          this.$message.success('更新成功!')
-          this.dialogVisible_update = false
-          this.getPage()
+          this.$message.success("更新成功!");
+          this.dialogVisible_update = false;
+          this.getPage();
         }
-      })
+      });
     },
 
     // 确定
     getSubmit() {
       if (this.$route.query.row) {
-        edit(this.form_create).then(res => {
+        edit(this.form_create).then((res) => {
           if (res.code === 0) {
-            this.$message.success('修改成功!')
-            this.getCancel()
+            this.$message.success("修改成功!");
+            this.getCancel();
           }
-        })
+        });
       } else {
-        add(this.form_create).then(res => {
+        add(this.form_create).then((res) => {
           if (res.code === 0) {
-            this.$message.success('新增成功!')
-            this.getCancel()
+            this.$message.success("新增成功!");
+            this.getCancel();
           }
-        })
+        });
       }
     },
 
@@ -283,10 +287,10 @@ export default {
     },
 
     statusFormatter(row) {
-      return this.selectDictLabel(this.statusOptions, row.status)
-    }
-  }
-}
+      return this.selectDictLabel(this.statusOptions, row.status);
+    },
+  },
+};
 </script>
 
 <style lang="scss" scoped>

+ 16 - 5
src/views/project/list/index.vue

@@ -7,7 +7,7 @@
       </el-form-item>
       <el-form-item label="当前状态:">
         <el-select v-model="form.status" placeholder="请选择当前状态">
-          <el-option />
+          <el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
         </el-select>
       </el-form-item>
       <el-form-item>
@@ -21,7 +21,7 @@
       <el-table-column prop="name" label="项目名称" align="center" />
       <el-table-column label="创建时间" align="center" />
       <el-table-column label="创建人" align="center" />
-      <el-table-column label="当前状态" align="center" />
+      <el-table-column prop="status" label="当前状态" align="center" :formatter="statusFormatter"/>
       <el-table-column label="操作" align="center">
         <template slot-scope="scope">
           <el-button type="text" @click="getDetail(scope.row, 'edit')">管理</el-button>
@@ -38,7 +38,9 @@
 
 <script>
 import { page } from '@/api/project/list'
+import { statusMixin } from '../mixin/index';
 export default {
+  mixins: [statusMixin],
   data() {
     return {
       // 表单
@@ -67,12 +69,17 @@ export default {
 
     // 搜索
     getSearch() {
-
+      this.form.pageNum = 1
+      this.getList()
     },
 
     // 重置
     getRefresh() {
-
+      this.form = {
+        pageNum: 1,
+        pageSize: 10
+      }
+      this.getList()
     },
 
     // 新增 / 管理
@@ -84,7 +91,11 @@ export default {
           key: key
         }
       })
-    }
+    },
+    
+    statusFormatter(row) {
+      return this.selectDictLabel(this.statusOptions, row.status);
+    },
   }
 }
 </script>

+ 17 - 0
src/views/project/mixin/index.js

@@ -0,0 +1,17 @@
+const statusMixin = {
+    data() {
+        return {
+            statusOptions: [{
+                value: 0,
+                label: '未发布'
+            }, {
+                value: 1,
+                label: '已发布'
+            }]
+        }
+    }
+}
+
+export {
+    statusMixin
+}