diff --git a/src/assets/styles/globals.scss b/src/assets/styles/globals.scss index 3ee3331..0ea0555 100644 --- a/src/assets/styles/globals.scss +++ b/src/assets/styles/globals.scss @@ -118,3 +118,7 @@ .el-button.is-link + .el-button.is-link { margin-left: 3px; } + +.full-width-input { + width: 100% !important; +} diff --git a/src/assets/styles/globals.scss b/src/assets/styles/globals.scss index 3ee3331..0ea0555 100644 --- a/src/assets/styles/globals.scss +++ b/src/assets/styles/globals.scss @@ -118,3 +118,7 @@ .el-button.is-link + .el-button.is-link { margin-left: 3px; } + +.full-width-input { + width: 100% !important; +} diff --git a/src/components/NormalTable/index.vue b/src/components/NormalTable/index.vue index 046291a..1c14871 100644 --- a/src/components/NormalTable/index.vue +++ b/src/components/NormalTable/index.vue @@ -27,7 +27,7 @@ }, }, // loading状态 - loading: { + listLoading: { type: Boolean, default: false, }, @@ -163,7 +163,7 @@ console.log('selectClick') if (selection.length > 1) { const del_row = selection.shift() - table.value.toggleRowSelection(del_row, false) // 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中) + table.value?.toggleRowSelection(del_row, false) // 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中) } } } @@ -174,7 +174,7 @@ - + diff --git a/src/assets/styles/globals.scss b/src/assets/styles/globals.scss index 3ee3331..0ea0555 100644 --- a/src/assets/styles/globals.scss +++ b/src/assets/styles/globals.scss @@ -118,3 +118,7 @@ .el-button.is-link + .el-button.is-link { margin-left: 3px; } + +.full-width-input { + width: 100% !important; +} diff --git a/src/components/NormalTable/index.vue b/src/components/NormalTable/index.vue index 046291a..1c14871 100644 --- a/src/components/NormalTable/index.vue +++ b/src/components/NormalTable/index.vue @@ -27,7 +27,7 @@ }, }, // loading状态 - loading: { + listLoading: { type: Boolean, default: false, }, @@ -163,7 +163,7 @@ console.log('selectClick') if (selection.length > 1) { const del_row = selection.shift() - table.value.toggleRowSelection(del_row, false) // 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中) + table.value?.toggleRowSelection(del_row, false) // 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中) } } } @@ -174,7 +174,7 @@ - + diff --git a/src/router/modules/measure.ts b/src/router/modules/measure.ts index 3676c67..ad8790d 100644 --- a/src/router/modules/measure.ts +++ b/src/router/modules/measure.ts @@ -266,7 +266,7 @@ { path: '/price', component: Layout, - redirect: '/measure/measurePrice/list', + redirect: '/price/list', name: 'MeasurePrice', meta: { title: '价格库', @@ -284,6 +284,19 @@ auth: '/measure/measurePrice/list', }, }, + { + path: ':type/:id?', + name: 'measurePriceAdd', + component: () => import('@/views/measure/price/priceAdd.vue'), + meta: { + title: '新建价格', + icon: 'ep:key', + sidebar: false, + breadcrumb: true, + auth: '/measure/price/add', + activeMenu: '/price/list', + }, + }, ], }, ] diff --git a/src/assets/styles/globals.scss b/src/assets/styles/globals.scss index 3ee3331..0ea0555 100644 --- a/src/assets/styles/globals.scss +++ b/src/assets/styles/globals.scss @@ -118,3 +118,7 @@ .el-button.is-link + .el-button.is-link { margin-left: 3px; } + +.full-width-input { + width: 100% !important; +} diff --git a/src/components/NormalTable/index.vue b/src/components/NormalTable/index.vue index 046291a..1c14871 100644 --- a/src/components/NormalTable/index.vue +++ b/src/components/NormalTable/index.vue @@ -27,7 +27,7 @@ }, }, // loading状态 - loading: { + listLoading: { type: Boolean, default: false, }, @@ -163,7 +163,7 @@ console.log('selectClick') if (selection.length > 1) { const del_row = selection.shift() - table.value.toggleRowSelection(del_row, false) // 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中) + table.value?.toggleRowSelection(del_row, false) // 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中) } } } @@ -174,7 +174,7 @@ - + diff --git a/src/router/modules/measure.ts b/src/router/modules/measure.ts index 3676c67..ad8790d 100644 --- a/src/router/modules/measure.ts +++ b/src/router/modules/measure.ts @@ -266,7 +266,7 @@ { path: '/price', component: Layout, - redirect: '/measure/measurePrice/list', + redirect: '/price/list', name: 'MeasurePrice', meta: { title: '价格库', @@ -284,6 +284,19 @@ auth: '/measure/measurePrice/list', }, }, + { + path: ':type/:id?', + name: 'measurePriceAdd', + component: () => import('@/views/measure/price/priceAdd.vue'), + meta: { + title: '新建价格', + icon: 'ep:key', + sidebar: false, + breadcrumb: true, + auth: '/measure/price/add', + activeMenu: '/price/list', + }, + }, ], }, ] diff --git a/src/utils/validate.ts b/src/utils/validate.ts new file mode 100644 index 0000000..bb58885 --- /dev/null +++ b/src/utils/validate.ts @@ -0,0 +1,55 @@ +/** + * 判断是否为空 + * @param val 待判断值 + * @returns 是否合法 + */ +export const isRequired = (val: string): boolean => { + return val !== '' +} + +// +/** + * 判断是否为整数 + * @param value + * @returns 是否合法 + */ +export const isInteger = (value: any) => { + return Number.isInteger(Number(value)) +} + +/** + * 判断是否为ip + * @param ip 待判断 + * @returns 是否合法 + */ +export const isIp = (ip: string): boolean => { + var rep = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/ + return rep.test(ip) +} + +/** + * 判断端口是否合法 + * @param port 待判断端口 + * @returns 是否合法 + */ +export const isPort = (port: number | string): boolean => { + if (!isInteger(port) || port > 65535 || port < 1) { + return false + } + return true +} + +// +/** + * 判断整数范围 + * @param value 待判断数值 + * @param max 最大值 + * @param min 最小值 + * @returns 是否符合数值范围 + */ +export const isInRange = (value: number, max = 20, min = -10): boolean => { + if (!isInteger(value) || value > max || min < -10) { + return false + } + return true +} diff --git a/src/assets/styles/globals.scss b/src/assets/styles/globals.scss index 3ee3331..0ea0555 100644 --- a/src/assets/styles/globals.scss +++ b/src/assets/styles/globals.scss @@ -118,3 +118,7 @@ .el-button.is-link + .el-button.is-link { margin-left: 3px; } + +.full-width-input { + width: 100% !important; +} diff --git a/src/components/NormalTable/index.vue b/src/components/NormalTable/index.vue index 046291a..1c14871 100644 --- a/src/components/NormalTable/index.vue +++ b/src/components/NormalTable/index.vue @@ -27,7 +27,7 @@ }, }, // loading状态 - loading: { + listLoading: { type: Boolean, default: false, }, @@ -163,7 +163,7 @@ console.log('selectClick') if (selection.length > 1) { const del_row = selection.shift() - table.value.toggleRowSelection(del_row, false) // 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中) + table.value?.toggleRowSelection(del_row, false) // 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中) } } } @@ -174,7 +174,7 @@ - + diff --git a/src/router/modules/measure.ts b/src/router/modules/measure.ts index 3676c67..ad8790d 100644 --- a/src/router/modules/measure.ts +++ b/src/router/modules/measure.ts @@ -266,7 +266,7 @@ { path: '/price', component: Layout, - redirect: '/measure/measurePrice/list', + redirect: '/price/list', name: 'MeasurePrice', meta: { title: '价格库', @@ -284,6 +284,19 @@ auth: '/measure/measurePrice/list', }, }, + { + path: ':type/:id?', + name: 'measurePriceAdd', + component: () => import('@/views/measure/price/priceAdd.vue'), + meta: { + title: '新建价格', + icon: 'ep:key', + sidebar: false, + breadcrumb: true, + auth: '/measure/price/add', + activeMenu: '/price/list', + }, + }, ], }, ] diff --git a/src/utils/validate.ts b/src/utils/validate.ts new file mode 100644 index 0000000..bb58885 --- /dev/null +++ b/src/utils/validate.ts @@ -0,0 +1,55 @@ +/** + * 判断是否为空 + * @param val 待判断值 + * @returns 是否合法 + */ +export const isRequired = (val: string): boolean => { + return val !== '' +} + +// +/** + * 判断是否为整数 + * @param value + * @returns 是否合法 + */ +export const isInteger = (value: any) => { + return Number.isInteger(Number(value)) +} + +/** + * 判断是否为ip + * @param ip 待判断 + * @returns 是否合法 + */ +export const isIp = (ip: string): boolean => { + var rep = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/ + return rep.test(ip) +} + +/** + * 判断端口是否合法 + * @param port 待判断端口 + * @returns 是否合法 + */ +export const isPort = (port: number | string): boolean => { + if (!isInteger(port) || port > 65535 || port < 1) { + return false + } + return true +} + +// +/** + * 判断整数范围 + * @param value 待判断数值 + * @param max 最大值 + * @param min 最小值 + * @returns 是否符合数值范围 + */ +export const isInRange = (value: number, max = 20, min = -10): boolean => { + if (!isInteger(value) || value > max || min < -10) { + return false + } + return true +} diff --git a/src/views/measure/price/list.vue b/src/views/measure/price/list.vue index b6d4f2f..cbed390 100644 --- a/src/views/measure/price/list.vue +++ b/src/views/measure/price/list.vue @@ -2,92 +2,42 @@ import { getCurrentInstance, ref } from 'vue' import type { Ref } from 'vue' import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' -import type { IlistQuery, IlistType, optionsType } from './list_interface' +import { useRoute, useRouter } from 'vue-router' +import type { IlistQuery, IlistType, optionsType, priceForm } from './list_interface' import ListPriceAdd from './priceAdd.vue' import { getDeletePrice, getPriceList, getTypeSelect, uploadPrice } from '@/api/system/price' import { exportExcel } from '@/utils/exportXlsx' +import type { TableColumn } from '@/components/NormalTable/table_interface' // 查询条件 const listQuery: Ref = ref({ - checkType: '', - // model: '', - priceItem: '', - priceName: '', - priceNo: '', - priceType: '', - offset: 1, - limit: 10, + checkType: '', // 检校类型 + priceItem: '', // 项目 + priceName: '', // 价格名称 + priceNo: '', // 价格编号 + priceType: '', // 类别 + offset: 1, // 页码 + limit: 20, // 分页数量 }) // 控制是否显示新增页面 const show = ref(true) // 表格数据 const list = ref([]) // 总数 -const total = ref(20) +const total = ref(0) // 表头 -const columns = ref([ - { - text: '价格编号', - value: 'priceNo', - width: '160', - align: 'center', - }, - { - text: '价格名称', - value: 'priceName', - width: '90', - align: 'center', - }, - { - text: '检校类型', - value: 'checkType', - width: '90', - align: 'center', - }, - // { - // text: '型号', - // value: 'model', - // }, - { - text: '类别', - value: 'priceType', - align: 'center', - }, - { - text: '项目', - value: 'priceItem', - align: 'center', - }, - { - text: '标准价格(元)', - value: 'price', - width: '120', - align: 'center', - }, - { - text: '业务员折扣权限', - value: 'operatorDiscountPermission', - width: '130', - align: 'center', - }, - { - text: '负责人折扣权限', - value: 'directorDiscountPermission', - width: '130', - align: 'center', - }, - { - text: '依据标准', - value: 'priceStandard', - width: '90', - align: 'center', - }, - { - text: '创建时间', - value: 'createTime', - width: '120', - align: 'center', - }, -]) +const columns: Ref = ref([]) +columns.value = [ + { text: '价格编号', value: 'priceNo', width: '140', align: 'center' }, + { text: '价格名称', value: 'priceName', align: 'center' }, + { text: '检校类型', value: 'checkType', align: 'center' }, + { text: '类别', value: 'priceType', align: 'center' }, + { text: '项目', value: 'priceItem', align: 'center' }, + { text: '标准价格(元)', value: 'price', width: '120', align: 'center' }, + { text: '业务员折扣权限', value: 'operatorDiscountPermission', width: '125', align: 'center' }, + { text: '负责人折扣权限', value: 'directorDiscountPermission', width: '125', align: 'center' }, + { text: '依据标准', value: 'priceStandard', width: '90', align: 'center' }, + { text: '创建时间', value: 'createTime', width: '170', align: 'center' }, +] // 选中的内容 const checkoutList = ref([]) @@ -95,19 +45,22 @@ const fileRef = ref() // 删除id const deleteId = ref('') -// 详情id -const infoId = ref('0') // 校验类型下拉框数组 const checkTypeOptions = ref([]) // 类别下拉框数组 const priceTypeOptions = ref([]) // 项目下拉框数组 const priceItemOptions = ref([]) +// 确认框是否显示 const isPopconfirmShow = ref(false) -// 点击按钮 -const buttonType = ref('') + +// 列表加载状态 const loadingTable = ref(false) -const fetchData = (isNowPage: boolean) => { +// 查询列表 +const fetchData = (isNowPage = false) => { + if (!isNowPage) { + listQuery.value.offset = 1 + } loadingTable.value = true getPriceList(listQuery.value).then((response) => { list.value = response.data.records @@ -120,19 +73,14 @@ const handleSelectionChange = (e: any) => { checkoutList.value = e } -// 点击编辑id和删除row类型 -interface rowReturn { - id: string - priceName: string -} + +const $router = useRouter() // 点击编辑/详情 -const handleEdit = (index: string, row: rowReturn, value: string) => { - buttonType.value = value - infoId.value = row.id - show.value = false +const handleEdit = (row: priceForm, pageType: 'edit' | 'detail') => { + $router.push(`/price/${pageType}/${row.id}`) } // 点击删除 -const handleDelete = (index: string, row: rowReturn) => { +const handleDelete = (row: priceForm) => { console.log(row) ElMessageBox.confirm( `确认删除${row.priceName}吗?`, @@ -144,7 +92,7 @@ }, ) .then(() => { - getDeletePrice({ id: row.id as string }).then((res) => { + getDeletePrice({ id: row.id }).then((res) => { if (res.code === 200) { ElMessage({ type: 'success', @@ -157,8 +105,9 @@ } // 点击搜索 const searchList = () => { - fetchData(true) + fetchData() } +// 确认删除 const confirmEvent = () => { getDeletePrice({ id: deleteId.value }).then((res) => { if (res.code === 200) { @@ -168,9 +117,7 @@ } }) } -const cancelEvent = () => { - console.log('cancel!') -} + // 获取下拉框数据 const getOptions = (code: string) => { getTypeSelect(code).then((res) => { @@ -197,13 +144,9 @@ priceNo: '', priceType: '', offset: 1, - limit: 10, + limit: 20, } -} -// 关闭编辑 -const close = () => { - show.value = true - fetchData(true) + fetchData() } const { proxy } = getCurrentInstance() as any // 导出 @@ -272,9 +215,9 @@ const uploadAll = () => { upload() } + const add = () => { - buttonType.value = '新建' - show.value = false + $router.push('/price/add') } const exportAll = () => { exportExcelBtn() @@ -282,7 +225,7 @@ // 打印 const printObj = ref({ id: 'print', // 需要打印元素的id - popTitle: '溯源供方编号模板', // 打印配置页上方的标题 + popTitle: '价格列表', // 打印配置页上方的标题 extraHead: '', // 最上方的头部文字,附加在head标签上的额外标签,使用逗号分割 preview: false, // 是否启动预览模式,默认是false standard: '', @@ -291,7 +234,7 @@