Skip to content

Commit

Permalink
feat: noImplicitAny: true
Browse files Browse the repository at this point in the history
  • Loading branch information
greper committed Jan 31, 2023
1 parent 9092d1f commit 47c444b
Show file tree
Hide file tree
Showing 27 changed files with 153 additions and 283 deletions.
2 changes: 1 addition & 1 deletion packages/fast-admin/fs-admin-antdv
2 changes: 1 addition & 1 deletion packages/fast-crud/src/components/basic/fs-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default defineComponent({
},
setup(props, ctx) {
const { ui } = useUi();
const iconRender = (icon, iconClass = "fs-button-icon") => {
const iconRender = (icon: any, iconClass = "fs-button-icon") => {
if (icon == null) {
return;
}
Expand Down
29 changes: 14 additions & 15 deletions packages/fast-crud/src/components/basic/fs-icon-svg.vue
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
<template>
<span :class="['fs-icon-svg', spin && 'fs-icon-spin']">
<svg class="fs-icon-svg-content" aria-hidden="true">
<use :xlink:href="symbolId"></use>
</svg>
<use :xlink:href="symbolId"></use>
</svg>
</span>

</template>
<script lang="ts">
import type {CSSProperties} from 'vue';
import {defineComponent, computed} from 'vue';
import type { CSSProperties } from "vue";
import { defineComponent, computed } from "vue";
export default defineComponent({
name: 'FsSvgIcon',
name: "FsSvgIcon",
props: {
icon: {
type: String,
required: true,
required: true
},
size: {
type: [Number, String],
default: 16,
default: 16
},
spin: {
type: Boolean,
default: false,
},
default: false
}
},
setup(props) {
const symbolId = computed(() => `#${props.icon}`);
const getStyle = computed((): CSSProperties => {
const {size} = props;
const { size } = props;
let s = `${size}`;
s = `${s.replace('px', '')}px`;
s = `${s.replace("px", "")}px`;
return {
width: s,
height: s,
height: s
};
});
return {symbolId, getStyle};
},
return { symbolId, getStyle };
}
});
</script>
<style lang="less">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
columnKey: {},
editable: {}
},
setup(props, ctx) {
setup(props: any, ctx: any) {
const ui = uiContext.get();
// const getEditable = inject("get:editable");
const { doComputed } = useCompute();
Expand All @@ -32,11 +32,11 @@ export default {
return props.editable?.getForm();
};

let computedForm = doComputed(getFormRefFunc, () => {
const computedForm = doComputed(getFormRefFunc, () => {
return props.scope;
});

let computedIsEditable = computed(() => {
const computedIsEditable = computed(() => {
return computedForm.value && computedForm.value.show !== false && props.editable?.isEditable();
});

Expand Down Expand Up @@ -100,7 +100,9 @@ export default {
};
},
methods: {
//@ts-ignore
getTargetRef() {
//@ts-ignore
return this.$refs.targetRef?.getTargetRef();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import _ from "lodash-es";
import { reactive, computed, provide, nextTick, ref, watch } from "vue";
import { computed, reactive, watch } from "vue";
import { uiContext } from "../../../ui";

// import { useValidation } from "./validation/use-validation";

function useTableData(props, tableRef) {
function useTableData(props: any, tableRef: any) {
const ui = uiContext.get();

function getData() {
Expand All @@ -19,27 +19,27 @@ function useTableData(props, tableRef) {

return {
getData,
insert(index, row) {
insert(index: number, row: any) {
getData().splice(index, 0, row);
},
unshift(row) {
unshift(row: any) {
getData().unshift(row);
},
remove(index) {
remove(index: number) {
getData().splice(index, 1);
},
get(index) {
get(index: number) {
return getData()[index];
}
};
}

export function useEditable(props, ctx, tableRef) {
export function useEditable(props: any, ctx: any, tableRef: any) {
const tableData = useTableData(props, tableRef);
const editableRows = reactive([]);
const actionHistory = reactive([]);

function editableRowsEach(call) {
function editableRowsEach(call: (opts: any) => any) {
for (let i = 0; i < editableRows.length; i++) {
const row = editableRows[i];
const cells = row.cells;
Expand All @@ -51,7 +51,7 @@ export function useEditable(props, ctx, tableRef) {
}
}

function editableEach(call) {
function editableEach(call: (opts: any) => any) {
editableRowsEach(({ rowData, row, cells, index }) => {
_.forEach(cells, (cell, key) => {
call({ rowData, row, cells, cell, index, key });
Expand All @@ -71,7 +71,7 @@ export function useEditable(props, ctx, tableRef) {
exclusive: true, //是否排他式激活,激活一个,关闭其他
activeTrigger: "onClick", //激活触发方式,onClick,onDbClick,false
activeDefault: false,
isEditable({ index, key, row }) {
isEditable(opts: { index: number; key: string; row: any }) {
return true;
},
cell: {
Expand All @@ -84,16 +84,16 @@ export function useEditable(props, ctx, tableRef) {
);
});

function createEditableCell(tableRow, key, index) {
function getValue(key) {
function createEditableCell(tableRow: any, key: string, index: number) {
function getValue(key: string) {
return tableRow[key];
}

function setValue(key, value) {
function setValue(key: string, value: any) {
tableRow[key] = value;
}

const cell = reactive({
const cell: any = reactive({
isEditing: options.value.activeDefault,
activeTrigger: options.value.activeTrigger
});
Expand All @@ -110,7 +110,7 @@ export function useEditable(props, ctx, tableRef) {
}
return form[key];
};
cell.active = (opts = {}) => {
cell.active = (opts: any = {}) => {
const exclusive = opts.exclusive ?? options.value.exclusive;
if (exclusive) {
inactive();
Expand Down Expand Up @@ -140,8 +140,8 @@ export function useEditable(props, ctx, tableRef) {
return cell;
}

function createEditableRow(index, rowData) {
const cells = {};
function createEditableRow(index: number, rowData: any) {
const cells: any = {};
_.forEach(props.columns, (item) => {
const config = item.editable ?? {};
let disabled = config.disabled ?? false;
Expand All @@ -152,7 +152,7 @@ export function useEditable(props, ctx, tableRef) {
cells[item.key] = createEditableCell(rowData, item.key, index);
}
});
const editableRow = (editableRows[index] = reactive({ cells }));
const editableRow: any = (editableRows[index] = reactive({ cells }));

editableRow.inactive = () => {
editableRow.isEditing = false;
Expand Down Expand Up @@ -183,11 +183,12 @@ export function useEditable(props, ctx, tableRef) {
});
};

editableRow.save = async ({ index, doSave }) => {
editableRow.save = async (opts: { index: number; doSave: (opts: any) => Promise<void> }) => {
const { index, doSave } = opts;
const changed = editableRow.getChangeData(index);
const row = tableData.get(index);

function setData(newRow) {
function setData(newRow: any) {
if (newRow) {
_.merge(row, newRow);
}
Expand All @@ -197,18 +198,18 @@ export function useEditable(props, ctx, tableRef) {
editableRow.persist();
};

editableRow.getRowData = (index) => {
editableRow.getRowData = (index: number) => {
return tableData.get(index);
};
editableRow.getChangeData = (index) => {
editableRow.getChangeData = (index: number) => {
editableRow.inactive();
const row = editableRow;
const rowData = tableData.get(index);
if (row.isAdd) {
return rowData;
}
const id = rowData[options.value.rowKey];
const changed = { [options.value.rowKey]: id };
const changed: any = { [options.value.rowKey]: id };
_.forEach(row.cells, (cell, key) => {
if (cell.isChanged()) {
changed[key] = cell.newValue;
Expand All @@ -219,17 +220,17 @@ export function useEditable(props, ctx, tableRef) {
return editableRow;
}

function unshiftEditableRow(rowData, index = 0) {
function unshiftEditableRow(rowData: any, index = 0) {
editableRows.splice(index, 0, { cells: {} });
return createEditableRow(index, rowData);
}

function setupEditable(data) {
function setupEditable(data?: any) {
if (data == null) {
data = tableData.getData();
}
editableRows.length = 0;
_.forEach(data, (rowData, index) => {
_.forEach(data, (rowData: any, index: number) => {
createEditableRow(index, rowData);
});
if (options.value.onSetup) {
Expand Down Expand Up @@ -280,7 +281,7 @@ export function useEditable(props, ctx, tableRef) {
}
);

function getEditableCell(index, key) {
function getEditableCell(index?: number, key?: string) {
if (key == null || index < 0) {
return {};
}
Expand Down Expand Up @@ -312,11 +313,11 @@ export function useEditable(props, ctx, tableRef) {
* @returns {[]}
*/
function getChangedData() {
const changedRows = [];
const removedRows = [];
const changedRows: any[] = [];
const removedRows: any[] = [];
editableRowsEach(({ rowData, row, cells }) => {
const id = rowData[options.value.rowKey];
const changed = { [options.value.rowKey]: id };
const changed: any = { [options.value.rowKey]: id };
let hasChange = row.isAdd || false;
_.forEach(cells, (cell, key) => {
if (cell.isChanged()) {
Expand Down Expand Up @@ -387,11 +388,11 @@ export function useEditable(props, ctx, tableRef) {
});
}

async function submit(call) {
async function submit(call: (opts: any) => any) {
inactive();
const changed = getChangedData();

function setData(list) {
function setData(list: any[]) {
_.forEach(list, (row, index) => {
_.merge(tableData.get(index), row);
});
Expand All @@ -416,11 +417,11 @@ export function useEditable(props, ctx, tableRef) {

let addIndex = 0;

function addRow(opts = {}) {
function addRow(opts: { row: any } = { row: undefined }) {
const row = opts.row || { [options.value.rowKey]: --addIndex };
if (opts.row === undefined) {
for (let i = 0; i < props.columns.length; i++) {
let value = props.columns[i].value;
const value = props.columns[i].value;
if (value || value === 0) {
row[props.columns[i].key] = value;
}
Expand All @@ -443,7 +444,7 @@ export function useEditable(props, ctx, tableRef) {
});
}

function removeRow(index) {
function removeRow(index: number) {
const editableRow = editableRows[index];
//把删除部分的数据临时保存起来
actionHistory.push({
Expand All @@ -456,15 +457,16 @@ export function useEditable(props, ctx, tableRef) {
tableData.remove(index);
}

function editCol({ cols }) {
function editCol(opts: { cols: any[] }) {
const { cols } = opts;
editableRowsEach(({ cells }) => {
_.forEach(cols, (key) => {
cells[key].active({ exclusive: false });
});
});
}

function getEditableRow(index) {
function getEditableRow(index: number) {
return editableRows[index];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import FsContainer from "./container/fs-container.vue";
import FsLayoutDefault from "./container/fs-layout-default.vue";
import FsLayoutCard from "./container/fs-layout-card.vue";

import FsButton from "./basic/fs-button.tsx";
import FsIcon from "./basic/fs-icon.tsx";
import FsButton from "./basic/fs-button";
import FsIcon from "./basic/fs-icon";
import FsIconify from "./basic/fs-iconify.vue";
import FsIconSvg from "./basic/fs-icon-svg.vue";

Expand All @@ -22,7 +22,7 @@ import FsCrud from "./fs-crud.vue";
import FsRowHandle from "./crud/fs-row-handle.vue";
import FsTable from "./crud/fs-table.jsx";
import FsCell from "./crud/fs-cell";
import FsEditableCell from "./crud/editable/fs-editable-cell.jsx";
import FsEditableCell from "./crud/editable/fs-editable-cell";
import FsActionbar from "./actionbar/index.vue";
import FsToolbar from "./toolbar/index.vue";
import FsSearch from "./search/index.vue";
Expand Down
Loading

0 comments on commit 47c444b

Please sign in to comment.