build.vue 5.51 KB
Newer Older
wanli's avatar
wanli committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<template>
  <div class="app-container">
    <el-form :inline="true" ref="form" :model="form" size="mini">
      <el-form-item label="应用名称" prop="uuid">
        <el-select v-model="form.uuid" filterable placeholder="请输入标题">
          <el-option
            v-for="(item, index) in roles"
            :key="index"
            :label="item.name"
            :value="item.uuid"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item
        ><el-button type="primary" @click="onSubmit"
          >查询</el-button
        ></el-form-item
      >
wanli's avatar
wanli committed
19
      <el-form-item><el-button @click="onReset('form')">重置</el-button></el-form-item>
wanli's avatar
wanli committed
20 21 22 23 24 25 26 27 28 29 30 31
    </el-form>
    <el-table
      v-loading="isLoading"
      element-loading-text="Loading"
      :data="list"
      size="mini"
      border
      stripe
      fit
      highlight-current-row
    >
      <el-table-column
wanli's avatar
wanli committed
32
        prop="app.app_name"
wanli's avatar
wanli committed
33
        label="应用名称"
wanli's avatar
wanli committed
34
        min-width="180"
wanli's avatar
wanli committed
35 36
      ></el-table-column>
      <el-table-column
wanli's avatar
wanli committed
37 38 39 40 41 42 43 44
        prop="app.app_url"
        label="应用路径"
        min-width="180"
      ></el-table-column>
      <el-table-column
        prop="app.app_version"
        label="应用版本"
        min-width="180"
wanli's avatar
wanli committed
45 46 47 48
      ></el-table-column>
      <el-table-column
        prop="create_at"
        label="创建时间"
wanli's avatar
wanli committed
49
        min-width="150"
wanli's avatar
wanli committed
50 51 52 53
      ></el-table-column>
      <el-table-column
        prop="create_by.username"
        label="创建者"
wanli's avatar
wanli committed
54
        min-width="150"
wanli's avatar
wanli committed
55
      ></el-table-column>
wanli's avatar
wanli committed
56
      <el-table-column label="操作" align="center" width="140" fixed="right">
wanli's avatar
wanli committed
57 58 59
        <template slot-scope="scope">
          <el-button
            size="mini"
wanli's avatar
wanli committed
60
            type="primary"
wanli's avatar
wanli committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
            @click="handleDownload(scope.$index, scope.row)"
            >下载</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <div class="page-wrapper">
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page.sync="form.pagenum"
        background
        small
        :page-size="form.pagesize"
        :pager-count="5"
        layout="pager, prev, next, total"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
import { getBuildLogsList } from "@/api/app-store";
import { mapTrim } from "@/utils/index";

export default {
  name: "AppBuild",
  data() {
    return {
      dialogImageUrl: "",
      disabled: false,
      total: 0,
      list: [],
      isLoading: false,
      roles: [],
      form: {
        uuid: null,
        name: null,
        pagesize: 15,
        pagenum: 1,
      },
      currentIndex: 0,
      currentValue: null,
      post: {
        name: null,
      },
      rules: {
        name: [
          {
            type: "string",
            required: true,
            message: "用户名不能为空",
            trigger: "blur",
          },
          {
            min: 1,
            max: 20,
            message: "字符串长度在 1 到 20 之间",
            trigger: "blur",
          },
        ],
      },
    };
  },
  methods: {
    fetchData(params) {
      this.isLoading = true;
      getBuildLogsList(params)
        .then((res) => {
          this.total = res.count;
          this.list = res.data.map(item => {
              item.build_text = JSON.stringify(item.app_info)
              return item
          });
        })
        .catch((err) => {
          // this.$message.error(err.message)
          console.log(err.message);
        })
        .finally(() => {
          this.isLoading = false;
        });
    },
    fetchSelectData() {
      getBuildLogsList({ scope_type: "list" })
        .then((res) => {
          if (res.code == 200) this.roles = res.data;
        })
        .catch((err) => {
          // this.$message.error(err.message)
          console.log(err.message);
        });
    },
    handleRemove(file) {
      console.log(file);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
    },
    handleDownload(index, row) {
wanli's avatar
wanli committed
160 161 162 163
        console.log(index);
        const body = document.getElementsByTagName("body")[0];
        const link = document.createElement("a");
        body.appendChild(link);
wanli's avatar
wanli committed
164
        link.target = "_blank";
wanli's avatar
wanli committed
165 166 167
        link.href = row.app_path;
        link.click();
        document.body.removeChild(link);
wanli's avatar
wanli committed
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
    },
    handleSizeChange(e) {
      this.form.pagesize = e;
      this.fetchData(mapTrim(this.form));
    },
    handleCurrentChange(e) {
      this.form.pagenum = e;
      this.fetchData(mapTrim(this.form));
    },
    handleEdit(index, row) {
      this.post = Object.assign(row);
      this.currentIndex = index;
      this.currentValue = row;
    },
    handleDelete(index, row) {
      this.$alert(
        "您确定要删除么?删除操作将不可恢复。如需取消操作,请点击右上角关闭按钮。",
        "删除提醒",
        {
          confirmButtonText: "确定",
          callback: (action) => {
            if (action == "confirm") console.log(action, index, row);
          },
        }
      );
    },
    onSubmit() {
      this.form.pagenum = 1;
      this.form.pagesize = 15;
      this.fetchData(mapTrim(this.form));
    },
    onReset(formName) {
      this.$refs[formName].resetFields();
      this.form.pagesize = 15;
      this.form.pagenum = 1;
      this.fetchData(mapTrim(this.form));
    },
  },
  mounted() {},
  created() {
    this.fetchData(mapTrim(this.form));
    this.fetchSelectData();
  },
};
</script>
<style lang="less" scoped>
.app-container {
  & > div.page-wrapper {
    margin: 10px 0px;
  }
}
</style>