+
@@ -32,8 +34,8 @@
@@ -63,20 +65,71 @@
-
+
批量删除
已选择
- 3
+ {{ selection.length }}
项
- 清空
+ 清空
新增SDK类型
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+
+
+ 确定
+
+
+
+
+
@@ -84,19 +137,66 @@
import helper from "@/services/helper.js";
import apassList from "@/components/apass-list";
import apassDialog from "@/components/apass-dialog";
+import apassUpload from "@/components/apass-upload";
import showMoreFilter from "@/components/show-more-filter";
export default {
components: {
apassList,
apassDialog,
+ apassUpload,
showMoreFilter,
},
data() {
return {
- paddingLeft: 25,
+ paddingLeft: 0,
listTotal: 0,
- listHeader: [{}],
+ listHeader: [
+ {
+ label: "SDK类型",
+ prop: "style_name",
+ type: "button",
+ width: 240,
+ },
+ {
+ label: "版本号",
+ prop: "version",
+ align: "center",
+ },
+ {
+ label: "是否提供SDK包下载",
+ prop: "is_sdk",
+ align: "center",
+ },
+ {
+ label: "操作人",
+ prop: "user_name",
+ align: "center",
+ },
+ {
+ label: "最后更新时间",
+ prop: "updated",
+ getText: ({ updated }) => this.getTimeText(updated || ""),
+ align: "center",
+ },
+ {
+ label: "操作",
+ type: "buttons",
+ align: "center",
+ width: 240,
+ actionList: [
+ {
+ label: "修改",
+ callback: this.editItem,
+ },
+ {
+ label: "删除",
+ callback: this.deleteItem,
+ class: "warn",
+ },
+ ],
+ },
+ ],
listData: [],
topFilter: {
type: "",
@@ -104,6 +204,24 @@ export default {
},
types: [],
tempFilter: {},
+ detailForm: {
+ type: 0, // 0:新增 1:修改
+ style_name: "",
+ version: "",
+ file_url: "",
+ },
+ detailFormRules: {
+ style_name: [
+ { required: true, message: "请填写SDK类型名称", trigger: "blur" },
+ { max: 20, message: "长度应小于20个字符", trigger: "change" },
+ ],
+ },
+ deleteDialogInfo: {
+ msg: "",
+ submit: null,
+ },
+ saveSection: false,
+ selection: [],
};
},
methods: {
@@ -114,12 +232,44 @@ export default {
};
this.tempFilter = filter;
+ this.saveSection = true;
+
+ this.$http
+ .get("/apaas/support/sdk/styles/list", {
+ params: {
+ style: fullFilter.type,
+ start: fullFilter.time && fullFilter.time[0],
+ end: fullFilter.time && fullFilter.time[1],
+ limit: fullFilter.size,
+ page: fullFilter.page,
+ },
+ })
+ .then(({ data }) => {
+ if (data.success === 1) {
+ this.listTotal = data.total;
+ this.listData = data.data || [];
+
+ this.$nextTick(() => {
+ this.selection.forEach((item) => {
+ let target = this.listData.find((v) => v.id === item.id);
+
+ if (target) {
+ this.setCurrentRow(target, true);
+ }
+ });
+ this.saveSection = false;
+ });
+ }
+ });
- console.log(fullFilter);
+ this.$http.get("/apaas/support/sdk/styleNames/list").then(({ data }) => {
+ if (data.success === 1) {
+ this.types = data.data || [];
+ }
+ });
},
topFilterClear() {
this.topFilter = {
- name: "",
type: "",
time: "",
};
@@ -131,38 +281,191 @@ export default {
refreshPage() {
this.$refs.list.resetCurrentPage();
},
- deleteSlectedItem() {
- console.log("deleteSlectedItem");
+ deleteSlection() {
+ this.deleteDialogInfo.msg = `确认删除要删除所选项吗?`;
+ this.deleteDialogInfo.submit = () => {
+ this.deleteRequest(this.selection.map((row) => row.id));
+ };
+ this.$refs.deleteDialog.show();
+ },
+ clearSelection() {
+ this.$refs.list.clearSelection();
},
- cleanSlectedItem() {
- console.log("cleanSlectedItem");
+ setCurrentRow(row, flag) {
+ this.$refs.list.setSelectedRow(row, flag);
},
addNewSdk() {
- console.log("addNewSdk");
+ this.detailForm = {
+ type: 0,
+ style_name: "",
+ version: "",
+ file_url: "",
+ };
+ this.$refs.detailDialog.show();
+ },
+ detailCancelAction() {
+ this.$refs.detailDialog.hide();
+ },
+ detailSubmitAction() {
+ if (this.detailForm.type === 0) {
+ this.$http
+ .post("/apaas/support/sdk/styles/create", {
+ style_name: this.detailForm.style_name,
+ version: this.detailForm.version,
+ file_url: this.detailForm.file_url,
+ })
+ .then(({ data }) => {
+ if (data.success === 1) {
+ this.$message.success("新增成功");
+ this.refreshPage();
+ this.$refs.detailDialog.hide();
+ } else {
+ this.$message.error("新增失败");
+ }
+ })
+ .catch((error) => {
+ console.log(error);
+ this.$message.error("新增失败");
+ });
+ } else {
+ this.$http
+ .put("/apaas/support/sdk/styles/put", {
+ id: this.detailForm.id,
+ style_name: this.detailForm.style_name,
+ version: this.detailForm.version,
+ file_url: this.detailForm.file_url,
+ })
+ .then(({ data }) => {
+ if (data.success === 1) {
+ this.$message.success("修改成功");
+ this.refreshPage();
+ this.$refs.detailDialog.hide();
+ } else {
+ this.$message.error("修改失败");
+ }
+ })
+ .catch((error) => {
+ console.log(error);
+ this.$message.error("修改失败");
+ });
+ }
+ },
+ editItem(item) {
+ this.detailForm = {
+ type: 1,
+ id: item.id,
+ style_name: item.style_name,
+ version: item.version,
+ file_url: item.file_url,
+ };
+ /* this.$http
+ .get("/apaas/support/sdk/styles/detail", {
+ params: {
+ id: item.id,
+ },
+ })
+ .then(({ data }) => {
+ if (data.success === 1) {
+ this.detailForm = data.data;
+ }
+ }); */
+ this.$refs.detailDialog.show();
+ },
+ deleteItem(item) {
+ this.deleteDialogInfo.msg = `确认删除${item.style_name}吗?`;
+ this.deleteDialogInfo.submit = () => {
+ this.deleteRequest([item.id]);
+ };
+ this.$refs.deleteDialog.show();
+ },
+ deleteRequest(ids) {
+ this.$http
+ .delete("/apaas/support/sdk/styles/delete", {
+ body: {
+ ids: ids,
+ },
+ })
+ .then(({ data }) => {
+ if (data.success === 1) {
+ this.$message.success("删除成功");
+ this.selection = [];
+ this.refreshPage();
+ } else {
+ this.$message.error("删除失败");
+ }
+ })
+ .catch((error) => {
+ console.log(error);
+ this.$message.error("删除失败");
+ });
+ },
+ getTimeText(time) {
+ return helper.dateStringTransform(time);
+ },
+ selectAction(values) {
+ if (this.saveSection) {
+ return;
+ }
+
+ let cleanPage = values.length === 0; // 是否清空当前页所有选中
+ let selection = [...this.selection];
+
+ if (cleanPage) {
+ selection = selection.filter((item) => {
+ return !this.listData.find((v) => {
+ return v.id === item.id;
+ });
+ });
+ } else {
+ selection.push(...values);
+ }
+
+ this.selection = selection;
},
},
};