test #47

Merged
gtz217 merged 273 commits from test into master 2023-10-17 08:53:54 +08:00
13 changed files with 9 additions and 348 deletions
Showing only changes of commit 56191453af - Show all commits

View File

@ -1,4 +1,4 @@
import DialogForm from '../components/dialogForm.vue'; import DialogForm from '@/components/DialogForm/index.vue';
export default { export default {
components: { DialogForm }, components: { DialogForm },

View File

@ -53,7 +53,7 @@ import {
exportEquipmentGroupExcel, exportEquipmentGroupExcel,
} from '@/api/base/equipmentGroup'; } from '@/api/base/equipmentGroup';
import moment from 'moment'; import moment from 'moment';
import basicPageMixin from '../mixin/basicPageMixin'; import basicPageMixin from '@/mixins/lb/basicPageMixin';
import { getAccessToken } from '@/utils/auth'; import { getAccessToken } from '@/utils/auth';
export default { export default {

View File

@ -1,115 +0,0 @@
import DialogForm from '../components/dialogForm.vue';
export default {
components: { DialogForm },
data() {
return {
// 遮罩层
loading: true,
// 导出遮罩层
exportLoading: false,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 质量检测信息基础列表
list: [],
// 弹出层标题
title: '',
// 是否显示弹出层
open: false,
// 列表数据
tableData: [],
// 弹窗的表单
// form: {}, // 占位
// 搜索框需要的 keys
// searchBarKeys: [], // 占位
// tableProps: [], // 占位
// tableBtn: [], // 占位
// searchBarFormConfig: [], // 占位
// // 弹窗表单配置
// dialogFormConfig: [], // 占位
};
},
mounted() {},
methods: {
// 过滤后端传回的详情数据
filterData(data, keys) {
const obj = {};
keys.forEach((key) => {
if (/time/i.test(key)) {
obj[key] = new Date(data[key]);
} else {
obj[key] = data[key];
}
});
return obj;
},
// 处理搜索条件
handleSearchBarBtnClick() {},
// 处理表格按钮
handleTableBtnClick({ data, type }) {
switch (type) {
case 'edit':
this.handleUpdate(data);
break;
case 'delete':
this.handleDelete(data);
break;
}
},
// 处理搜索栏按钮
handleSearchBarBtnClick(btn) {
// const keys = ['name', 'createTime']; // timeVal // 已被 searchBarKeys 替代
switch (btn.btnName) {
case 'search':
this.searchBarKeys.forEach((key) => {
if (key == 'timeVal') {
this.queryParams['startTime'] = btn.timeVal[0];
this.queryParams['endTime'] = btn.timeVal[1];
return;
}
this.queryParams[key] = btn[key] || null;
});
this.handleQuery();
break;
case 'add':
this.handleAdd();
break;
case 'export':
this.handleExport();
break;
case 'reset':
this.$refs['search-bar'].resetForm();
this.resetQuery();
break;
}
},
handleEmitFun({ action, value }) {
console.log('[Emit Fun]', action, value);
switch (action) {
// 查看详情
case 'show-detail':
this.$modal.msgSuccess('查看详情')
break;
}
},
// 获取列表数据
getList() {},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm('queryForm');
this.handleQuery();
},
/** 取消按钮 */
cancel() {
this.open = false;
this.reset();
},
},
};

View File

@ -122,7 +122,7 @@
<script> <script>
import moment from 'moment'; import moment from 'moment';
import basicPageMixin from '../mixin/basicPageMixin'; import basicPageMixin from '@/mixins/lb/basicPageMixin';
import { getAccessToken } from '@/utils/auth'; import { getAccessToken } from '@/utils/auth';
import { import {

View File

@ -43,7 +43,7 @@
<script> <script>
import moment from 'moment'; import moment from 'moment';
import basicPageMixin from '../mixin/basicPageMixin'; import basicPageMixin from '@/mixins/lb/basicPageMixin';
import { import {
createEquipmentType, createEquipmentType,

View File

@ -52,7 +52,7 @@ import {
getQualityInspectionBoxBtnPage, getQualityInspectionBoxBtnPage,
exportQualityInspectionBoxBtnExcel, exportQualityInspectionBoxBtnExcel,
} from '@/api/base/qualityInspectionBoxBtn'; } from '@/api/base/qualityInspectionBoxBtn';
import basicPageMixin from '../../mixin/basicPageMixin'; import basicPageMixin from '@/mixins/lb/basicPageMixin';
import moment from 'moment'; import moment from 'moment';
export default { export default {

View File

@ -89,7 +89,7 @@ import {
import moment from 'moment'; import moment from 'moment';
import basicPageMixin from '../../mixin/basicPageMixin'; import basicPageMixin from '@/mixins/lb/basicPageMixin';
export default { export default {
name: 'QualityInspectionDet', name: 'QualityInspectionDet',

View File

@ -77,7 +77,7 @@ import {
getQualityInspectionTypePage, getQualityInspectionTypePage,
exportQualityInspectionTypeExcel, exportQualityInspectionTypeExcel,
} from '@/api/base/qualityInspectionType'; } from '@/api/base/qualityInspectionType';
import basicPageMixin from '../../mixin/basicPageMixin'; import basicPageMixin from '@/mixins/lb/basicPageMixin';
export default { export default {
name: 'QualityInspectionType', name: 'QualityInspectionType',

View File

@ -1,208 +0,0 @@
<!--
filename: dialogForm.vue
author: liubin
date: 2023-08-02 10:32:36
description: 弹窗的表单组件
-->
<template>
<el-form
ref="form"
:model="form"
:label-width="`${labelWidth}px`"
v-loading="formLoading">
<el-row :gutter="20" v-for="(row, rindex) in rows" :key="rindex">
<el-col v-for="col in row" :key="col.label" :span="24 / row.length">
<el-form-item :label="col.label" :prop="col.prop" :rules="col.rules">
<el-input
v-if="col.input"
v-model="form[col.prop]"
@change="$emit('update', form)"
:placeholder="`请输入${col.label}`"
v-bind="col.bind" />
<el-input
v-if="col.textarea"
type="textarea"
v-model="form[col.prop]"
@change="$emit('update', form)"
:placeholder="`请输入${col.label}`"
v-bind="col.bind" />
<el-select
v-if="col.select"
v-model="form[col.prop]"
:placeholder="`请选择${col.label}`"
@change="$emit('update', form)"
v-bind="col.bind">
<el-option
v-for="opt in optionListOf[col.prop]"
:key="opt.value"
:label="opt.label"
:value="opt.value" />
</el-select>
<el-date-picker
v-if="col.datetime"
v-model="form[col.prop]"
type="datetime"
:placeholder="`请选择${col.label}`"
v-bind="col.bind"></el-date-picker>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
/**
* 找到最长的label
* @param {*} options
*/
function findMaxLabelWidth(rows) {
let max = 0;
rows.forEach((row) => {
row.forEach((opt) => {
if (opt.label.length > max) {
max = opt.label.length;
}
});
});
return max;
}
export default {
name: 'DialogForm',
model: {
prop: 'dataForm',
event: 'update',
},
emits: ['update'],
components: {},
props: {
rows: {
type: Array,
default: () => [],
},
dataForm: {
type: Object,
default: () => ({}),
},
},
data() {
return {
formLoading: true,
optionListOf: {},
};
},
computed: {
labelWidth() {
let max = findMaxLabelWidth(this.rows);
// 20px
return max * 20;
// return max * 20 + 'px';
},
form: {
get() {
return this.dataForm;
},
set(val) {
console.log('set form', val);
},
},
},
watch: {
rows: {
handler() {
console.log('watch triggered!');
this.$nextTick(() => {
this.handleOptions('watch');
});
},
deep: true,
immediate: false,
},
},
mounted() {
// options
this.handleOptions();
},
methods: {
/** 模拟透传 ref */
validate(cb) {
return this.$refs.form.validate(cb);
},
resetFields(args) {
return this.$refs.form.resetFields(args);
},
// getCode
async getCode(url) {
const response = await this.$axios(url);
return response.data;
},
async handleOptions(trigger = 'monuted') {
// console.log("[dialogForm:handleOptions]")
const promiseList = [];
this.rows.forEach((cols) => {
cols.forEach((opt) => {
if (opt.value && !this.form[opt.prop]) {
//
this.form[opt.prop] = opt.value;
}
if (opt.options) {
this.$set(this.optionListOf, opt.prop, opt.options);
} else if (opt.url) {
//
if (opt.select || (opt.input && !this.form?.id)) {
promiseList.push(async () => {
const response = await this.$axios(opt.url, {
method: opt.method ?? 'get',
});
console.log('[dialogForm:handleOptions:response]', response);
if (opt.select) {
//
const list =
'list' in response.data
? response.data.list
: response.data;
this.$set(
this.optionListOf,
opt.prop,
list.map((item) => ({
label: item[opt.labelKey ?? 'name'],
value: item[opt.valueKey ?? 'id'],
}))
);
} else if (opt.input) {
//
this.form[opt.prop] = response.data;
}
});
}
}
});
});
// watch
if (trigger == 'watch') {
this.formLoading = false;
return;
}
try {
await Promise.all(promiseList.map((fn) => fn()));
this.formLoading = false;
// console.log("[dialogForm:handleOptions:optionListOf]", this.optionListOf)
} catch (error) {
console.log('[dialogForm:handleOptions:error]', error);
this.formLoading = false;
}
if (!promiseList.length) this.formLoading = false;
},
},
};
</script>
<style scoped lang="scss">
.el-date-editor,
.el-select {
width: 100%;
}
</style>

View File

@ -55,7 +55,7 @@ import {
import Editor from '@/components/Editor'; import Editor from '@/components/Editor';
import moment from 'moment'; import moment from 'moment';
import basicPageMixin from '../../mixin/basicPageMixin'; import basicPageMixin from '@/mixins/lb/basicPageMixin';
export default { export default {
name: 'QualityInspectionRecord', name: 'QualityInspectionRecord',
components: { components: {

View File

@ -13,14 +13,6 @@
:page="queryParams.pageNo" :page="queryParams.pageNo"
:limit="queryParams.pageSize" :limit="queryParams.pageSize"
:table-data="list"></base-table> :table-data="list"></base-table>
<!-- @emitFun="handleEmitFun"> -->
<!-- <method-btn
v-if="tableBtn.length"
slot="handleBtn"
label="操作"
fixed="right"
:method-list="tableBtn"
@clickBtn="handleTableBtnClick" /> -->
</template> </template>
<script> <script>

View File

@ -22,15 +22,7 @@
:page="queryParams.pageNo" :page="queryParams.pageNo"
:limit="queryParams.pageSize" :limit="queryParams.pageSize"
:table-data="list" :table-data="list"
@emitFun="handleEmitFun"> @emitFun="handleEmitFun"></base-table>
<!-- <method-btn
v-if="tableBtn.length"
slot="handleBtn"
label="操作"
fixed="right"
:method-list="tableBtn"
@clickBtn="handleTableBtnClick" /> -->
</base-table>
</template> </template>
<GraphPage <GraphPage