Manager.vue 8.24 KB
Newer Older
wanli's avatar
wanli committed
1 2 3 4 5
<template>
  <a-page-header-wrapper title="查询表格">
    <a-card :bordered="false">
      <div class="tableList">
        <div class="tableListForm">
6
          <a-form layout="inline">
wanli's avatar
wanli committed
7 8
            <a-row :gutter="{ md: 8, lg: 24, xl: 48 }">
              <a-col :md="8" :sm="24">
9 10
                <a-form-item label="版本号" v-decorator="['app_version']">
                  <a-input v-model="query.app_version" placeholder="请输入" />
wanli's avatar
wanli committed
11 12 13
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
14 15 16 17 18 19 20 21 22 23 24 25
                <a-form-item label="应用名称" v-decorator="['app_name']">
                  <a-select
                    v-model="query.app"
                    placeholder="请选择"
                    style="width: 100%"
                  >
                    <a-option
                      v-for="item in appList"
                      :key="item.uuid"
                      :value="item.uuid"
                      >{{ item.app_name }}</a-option
                    >
wanli's avatar
wanli committed
26 27 28 29 30
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <span class="submitButtons">
31 32 33 34 35 36 37 38 39 40
                  <a-button
                    type="primary"
                    htmlType="submit"
                    @click="getPackageList"
                  >
                    查询
                  </a-button>
                  <a-button :style="{ marginLeft: '8px' }" @click="resetForm">
                    重置
                  </a-button>
wanli's avatar
wanli committed
41 42 43 44 45 46 47 48
                </span>
              </a-col>
            </a-row>
          </a-form>
        </div>
        <div class="tableListOperator">
          <span v-show="selectedRowKeys.length > 0">
            <a-button>批量操作</a-button>
49 50 51
            <a-dropdown overlay="{menu}">
              <a-button> 更多操作 <icon type="down" /> </a-button>
            </a-dropdown>
wanli's avatar
wanli committed
52 53 54 55
          </span>
        </div>
        <a-table
          :columns="columns"
56 57 58
          :rowKey="(record) => record.uuid"
          :dataSource="tableData.list"
          :pagination="tableData.pagination"
wanli's avatar
wanli committed
59 60 61
          :loading="loading"
          @change="handleTableChange"
        >
62 63
          <template slot="record" slot-scope="record">
            {{ record.create_at }}
wanli's avatar
wanli committed
64 65 66 67 68 69 70 71
          </template>
          <template
            slot="expandedRowRender"
            slot-scope="record"
            style="margin: 0"
          >
            <p :style="[sya, syb]">
              <a-avatar
72
                :src="record.application.app_icon"
wanli's avatar
wanli committed
73 74 75 76
                shape="square"
                :size="128"
              />
            </p>
77
            <p :style="[sya]">EPK File Info</p>
wanli's avatar
wanli committed
78 79 80
            <a-row>
              <a-col :span="6">
                <a-description-item
81 82
                  title="Buffer Length"
                  :content="record.package_info.buff_length"
wanli's avatar
wanli committed
83 84 85 86
                />
              </a-col>
              <a-col :span="6">
                <a-description-item
87 88
                  title="Compress Level"
                  :content="record.package_info.compress_level"
wanli's avatar
wanli committed
89 90 91 92
                />
              </a-col>
              <a-col :span="6">
                <a-description-item
93 94
                  title="EPK Size"
                  :content="record.package_info.epk_filecontent_size"
wanli's avatar
wanli committed
95 96 97 98
                />
              </a-col>
              <a-col :span="6">
                <a-description-item
99 100
                  title="File Count"
                  :content="record.package_info.file_count"
wanli's avatar
wanli committed
101 102 103 104 105
                />
              </a-col>
            </a-row>
          </template>
          <template slot="action" slot-scope="text, record">
106
            <a href="javascript:;" @click="hadnleEdit(record)">编辑源文件</a>
wanli's avatar
wanli committed
107
            <a-divider type="vertical" />
108
            <a href="javascript:;" @click="handleDownload(record)">下载EPK</a>
wanli's avatar
wanli committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
          </template>
        </a-table>
      </div>
    </a-card>
  </a-page-header-wrapper>
</template>

<script>
import {
  Avatar,
  Row,
  Col,
  Card,
  List,
  Button,
  Form,
  Icon,
  Table,
  Divider,
  Dropdown,
  Input,
  Select,
  DatePicker,
132
  message,
wanli's avatar
wanli committed
133 134 135 136 137
} from "ant-design-vue";
import PageHeaderWrapper from "@/components/PageHeaderWrapper";
import DescriptionItem from "@/components/DescriptionItem";
const columns = [
  {
138 139 140 141
    title: "应用名称",
    dataIndex: "app_name",
    width: "15%",
    scopedSlots: { customRender: "pack" },
wanli's avatar
wanli committed
142 143
  },
  {
144 145
    title: "版本号",
    dataIndex: "app_version",
wanli's avatar
wanli committed
146 147 148 149
    sorter: true,
    scopedSlots: { customRender: "name" },
  },
  {
150 151
    title: "打包算法",
    dataIndex: "algorithm",
wanli's avatar
wanli committed
152
    filters: [
153 154
      { text: "zlib", value: "zlib" },
      { text: "heatshrink", value: "heatshrink" },
wanli's avatar
wanli committed
155 156 157
    ],
  },
  {
158
    title: "打包来源",
159
    dataIndex: "source_text",
160
    filters: [
161 162 163
      { text: "API", value: "API" },
      { text: "Frontend", value: "Frontend" },
      { text: "API", value: "API" },
164
    ],
wanli's avatar
wanli committed
165 166 167 168 169 170 171
  },
  {
    title: "Action",
    key: "action",
    scopedSlots: { customRender: "action" },
  },
];
172 173 174
// import { mapGetters } from "vuex";
import { mapTrim, download } from "@/utils/index";
import { getPackageList, getApplicationList } from "@/api/openapi";
175

wanli's avatar
wanli committed
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
export default {
  name: "ApplicationManager",
  data: () => ({
    selectedRowKeys: [],
    columns,
    sya: {
      fontSize: "16px",
      color: "rgba(0,0,0,0.85)",
      lineHeight: "24px",
      display: "block",
      marginBottom: "16px",
    },
    syb: {
      marginBottom: "24px",
    },
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
    loading: false,
    query: {
      app: null,
      app_name: null,
      app_version: null,
    },
    appList: [],
    post: {
      page: 1,
      pageSize: 15,
    },
    tableData: {
      list: [],
      pagination: {
        pageSize: 15,
        total: 200,
      },
    },
wanli's avatar
wanli committed
209 210
  }),
  components: {
211
    Icon,
wanli's avatar
wanli committed
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
    APageHeaderWrapper: PageHeaderWrapper,
    AAvatar: Avatar,
    ARow: Row,
    ACol: Col,
    ACard: Card,
    ACardGrid: Card.Grid,
    ACardMeta: Card.Meta,
    AList: List,
    AButton: Button,
    AForm: Form,
    AFormItem: Form.Item,
    AIcon: Icon,
    ATable: Table,
    ADescriptionItem: DescriptionItem,
    ADivider: Divider,
    ADropdown: Dropdown,
    AInput: Input,
    ASelect: Select,
    AOption: Select.Option,
    ARangePicker: DatePicker.RangePicker,
  },
  methods: {
234
    handleDownload(record) {
235
      download(`${record.app_name}_${record.app_version}.epk`, record.file_path)
wanli's avatar
wanli committed
236 237
        .then(() => {
          message.success("下载成功")
238
        })
wanli's avatar
wanli committed
239 240
        .catch(() => {
          message.error("下载失败")
241 242
        });
    },
243 244
    hadnleEdit(record) {
      this.$router.push({ name: "FileManager", params: { directory: record.file_dir, disk: "epks" } })
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
    },
    resetForm() {
      this.query = {
        app: null,
        app_name: null,
        app_version: null,
      };
      this.getPackageList()
    },
    getPackageList() {
      this.loading = true;
      let opts = mapTrim(this.query);
      opts = Object.assign(opts, this.post);

      getPackageList(opts)
        .then((res) => {
          message.success(res.msg);
          if (res.code == 200) {
263
            this.tableData.list = res.data.map(item => {
wanli's avatar
wanli committed
264
              if (item.source == 0) item.source_text = "Frontend"
265 266 267
              else item.source_text = "API"
              return item;
            });
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
            this.tableData.pagination.pageSize = res.pageSize;
            this.tableData.pagination.total = res.total;
          }
        })
        .catch((err) => {
          message.error(err.msg);
        })
        .finally(() => {
          this.loading = false;
        });
    },
    getApplicationList() {
      getApplicationList({ scope: "list" })
        .then((res) => {
          message.success(res.msg);
          this.appList = res.data;
        })
        .catch((err) => {
          message.error(err.msg);
        });
wanli's avatar
wanli committed
288 289 290 291 292 293
    },
    onSelectChange(selectedRowKeys) {
      window.console.log("selectedRowKeys changed: ", selectedRowKeys);
      this.selectedRowKeys = selectedRowKeys;
    },
    handleTableChange(pagination, filters, sorter) {
294 295 296 297
      console.log(pagination, filters, sorter);
      this.post.page = pagination.current;
      this.post.pageSize = pagination.pageSize;
      this.getPackageList();
wanli's avatar
wanli committed
298 299
    },
  },
300 301 302
  created() {
    this.getApplicationList();
    this.getPackageList();
wanli's avatar
wanli committed
303 304 305 306 307 308
  },
};
</script>
<style lang="less">
@import url("styles/tableList.less");
</style>