| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- <!-- 用户编辑弹窗 -->
- <template>
- <ele-modal
- width="1060px"
- :visible="visible"
- :append-to-body="true"
- :close-on-click-modal="false"
- custom-class="ele-dialog-form"
- :title="`给工序配置参数`"
- @update:visible="updateVisible"
- :maxable="true"
- >
- <div class="ele-body">
- <ele-pro-table
- ref="table"
- :needPage="false"
- :columns="columns"
- :datasource="datasource"
- >
- <!-- 表头工具栏 -->
- <template v-slot:toolbar>
- <el-button
- size="small"
- type="primary"
- icon="el-icon-plus"
- class="ele-btn-icon"
- @click="showAddLog"
- >
- 添加参数
- </el-button>
- </template>
- <!-- 描述 -->
- <template v-slot:description="{ row }">
- <el-input v-model="row.description" placeholder="请输入"></el-input>
- </template>
- <!-- 单位 -->
- <template v-slot:unitName="{ row }">
- <el-input v-model="row.unitName" placeholder="请输入"></el-input>
- </template>
- <!-- 上限 -->
- <template v-slot:maxValue="{ row }">
- <el-input v-model="row.maxValue" placeholder="请输入"></el-input>
- </template>
- <!-- 下限 -->
- <template v-slot:minValue="{ row }">
- <el-input v-model="row.minValue" placeholder="请输入"></el-input>
- </template>
- <!-- 默认值 -->
- <template v-slot:defaultValue="{ row }">
- <el-input v-model="row.defaultValue" placeholder="请输入"></el-input>
- </template>
- <!-- 默认值 -->
- <template v-slot:notNull="{ row }">
- <el-select v-model="row.notNull" placeholder="请选择">
- <el-option
- v-for="item in timeType"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </template>
- <!-- 状态列 -->
- <!-- 操作列 -->
- <template v-slot:action="{ row }">
- <el-popconfirm
- class="ele-action"
- title="确定要删除当前工序吗?"
- @confirm="remove(row)"
- >
- <template v-slot:reference>
- <el-link type="danger" :underline="false" icon="el-icon-delete">
- 删除
- </el-link>
- </template>
- </el-popconfirm>
- </template>
- </ele-pro-table>
- </div>
- <template v-slot:footer>
- <el-button @click="updateVisible(false)">取消</el-button>
- <el-button type="primary" :loading="loading" @click="save">
- 保存
- </el-button>
- </template>
- <ele-modal
- width="1720px"
- :visible="addDialog"
- :append-to-body="true"
- :close-on-click-modal="false"
- @update:visible="closeAdd"
- custom-class="ele-dialog-form"
- :maxable="true"
- >
- <Paramrter :data="tableData" ref="Paramrter" />
- <template v-slot:footer>
- <el-button @click="closeAdd">取消</el-button>
- <el-button type="primary" :loading="loading" @click="addParamrter">
- 添加
- </el-button>
- </template>
- </ele-modal>
- </ele-modal>
- </template>
- <script>
- import producetask from '@/api/technology/production';
- import Paramrter from './parameter';
- import { deepClone } from '@/components/FormGenerator/utils/index';
- export default {
- components: { Paramrter },
- props: {
- // 弹窗是否打开
- visible: Boolean,
- // 修改回显的数据
- data: Object
- },
- data() {
- return {
- timeType: [
- { value: 1, label: '是' },
- { value: 0, label: '否' }
- ],
- // 表格列配置
- columns: [
- {
- prop: 'paramName',
- label: '参数名称',
- showOverflowTooltip: true,
- align: 'center',
- minWidth: 110
- },
- {
- align: 'center',
- slot: 'description',
- prop: 'description',
- label: '文本描述',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'unitName',
- slot: 'unitName',
- label: '参数单位',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'maxValue',
- slot: 'maxValue',
- label: '参数上限',
- align: 'center',
- // showOverflowTooltip: true
- },
- {
- prop: 'minValue',
- slot: 'minValue',
- label: '参数下限',
- align: 'center',
- // showOverflowTooltip: true
- },
- {
- prop: 'defaultValue',
- slot: 'defaultValue',
- label: '默认值',
- align: 'center',
- // showOverflowTooltip: true
- },
- {
- prop: 'notNull',
- slot: 'notNull',
- label: '是否必填',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- columnKey: 'action',
- label: '操作',
- align: 'center',
- resizable: false,
- slot: 'action',
- showOverflowTooltip: true
- }
- ],
- loading: false,
- addDialog: false,
- removeList: [],
- tableData: []
- };
- },
- methods: {
- addParamrter() {
- let arr = deepClone(this.$refs.Paramrter.selection)
- arr.forEach((element) => {
- this.$set(element, 'paramId', element.id);
- this.$set(element, 'paramName', element.name);
- delete element.id;
- delete element.name;
- });
- this.$refs.table.setData([...arr, ...this.$refs.table.getData()]);
- this.closeAdd();
- },
- showAddLog() {
- this.tableData = this.$refs.table.getData()
- this.addDialog = true;
- },
- /*关闭选择参数*/
- closeAdd() {
- this.$refs.Paramrter.$refs.tableParameter.setSelectedRows([]);
- this.addDialog = false;
- },
- /* 刷新表格 */
- reload() {
- this.$refs.table.reload();
- },
- remove(row) {
- const data = this.$refs.table.getData() ?? [];
- if (row.id) {
- this.removeList.push(row.id);
- this.$refs.table.setData(data.filter((d) => d.id !== row.id));
- } else {
- this.$refs.table.setData(
- data.filter((d) => d.paramId !== row.paramId)
- );
- }
- },
- /* 表格数据源 */
- async datasource({ page, limit, where }) {
- if (this.data?.id) {
- const res = await producetask.paramList({
- taskId: this.data.id,
- pageNum: 1,
- size: -1
- });
- return res;
- }
- },
- /* 保存编辑 */
- save() {
- let arr = this.$refs.table.getData();
- arr.forEach((it) => {
- if (!it.taskId) {
- this.$set(it, 'taskId', this.data.id);
- }
- });
- if(!arr.length){
- return this.$message.warning('参数不能为空')
- }
- let canSave = true
- for(var i=0;i<arr.length;i++){
- const defaultValue = Number(arr[i].defaultValue)
- const maxValue = Number(arr[i].maxValue)
- const minValue = Number(arr[i].minValue)
- if(defaultValue!=''&maxValue!=''){
- if(defaultValue>maxValue||defaultValue==maxValue){
- this.$message.warning('默认值应小于参数上限')
- canSave = false
- break
- }
- }
- if(defaultValue!=''&minValue!=''){
- if(defaultValue<minValue||defaultValue==minValue){
- this.$message.warning('默认值应大于参数下限')
- canSave = false
- break
- }
- }
- if(maxValue!=''&minValue!=''){
- if(maxValue<minValue||maxValue==minValue){
- this.$message.warning('参数上限应大于参数下限')
- canSave = false
- break
- }
- }
- }
- if(canSave){
- producetask
- .paramSave({
- removeList: this.removeList,
- saveList: arr
- })
- .then((msg) => {
- if(msg){
- this.$message.success(msg);
- this.updateVisible(false);
- }
- });
- }
- // this.$refs.form.validate((valid) => {
- // if (!valid) {
- // return false;
- // }
- // if (!this.isUpdate) {
- // delete this.form.id;
- // }
- // this.form.workBeat.beatTimes = this.totalTime;
- // this.loading = true;
- // producetask
- // .save(this.form)
- // .then((msg) => {
- // this.form = {};
- // this.loading = false;
- // this.$message.success(msg);
- // this.updateVisible(false);
- // this.$emit('done');
- // })
- // .catch((e) => {
- // this.loading = false;
- // // this.$message.error(e.message);
- // });
- // });
- },
- /* 更新visible */
- updateVisible(value) {
- this.removeList = [];
- this.$emit('update:visible', value);
- }
- },
- watch: {
- visible(visible) {
- if (visible) {
- this.$nextTick(() => {
- this.reload();
- });
- }
- }
- }
- };
- </script>
|