于杰
10 天以前 9599b7f0354e0654d522fe4303ade7dd7aaa3680
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<script setup>
import {onMounted, ref} from "vue";
import {defineEmits} from 'vue';
import request from "@/utils/request";
import {ElMessage} from "element-plus";
import useUserInfoStore from "@/stores/userInfo";
import useOrderInfoStore from "@/stores/sd/order/orderInfo";
 
const userStore = useUserInfoStore()
const orderInfo = useOrderInfoStore()
const username = userStore.user.userName
 
onMounted(async() => {
  await firstLoading()
})
 
const firstLoading = async() => {
  request.post(`/glassOptimize/getConfiguration/修边/${username}`).then((res) => {
    if (res.code == "200") {
      const rawData = res.data.data;
      if (Array.isArray(rawData) && rawData.length > 0) {
        const formattedData = rawData.map(item => {
          const formattedItem = {};
          for (const key in item) {
            if (typeof item[key] === 'string') {
              //去除字符串属性值开头和结尾的双引号
              formattedItem[key] = item[key].replace(/^\"|\"$/g, '');
            } else {
              formattedItem[key] = item[key];
            }
          }
          return formattedItem;
        });
        quicksetLeft.value=formattedData[0].leftTrim
        quicksetTop.value=formattedData[0].upTrim
        quicksetRight.value=formattedData[0].rightTrim
        quicksetBottom.value=formattedData[0].downTrim
 
      }
    } else {
      ElMessage.warning(res.msg)
    }
  });
};
 
function setupComponent() {
  // 各个输入框绑定的值,初始化为0
  const quicksetTop = ref('0');
  const quicksetRight = ref('0');
  const quicksetBottom = ref('0');
  const quicksetLeft = ref('0');
  // 用于控制的输入值,初始化为1
  const controlValue = ref('1');
 
  const syncValues = () => {
    // 将控制值赋给其他四个组件
    quicksetTop.value = controlValue.value;
    quicksetRight.value = controlValue.value;
    quicksetBottom.value = controlValue.value;
    quicksetLeft.value = controlValue.value;
  };
  return {
    quicksetTop,
    quicksetRight,
    quicksetBottom,
    quicksetLeft,
    controlValue,
    syncValues
  };
}
const {
  quicksetTop,
  quicksetRight,
  quicksetBottom,
  quicksetLeft,
  controlValue,
  syncValues
} = setupComponent();
 
const check = ref(true)
 
 
const emit = defineEmits(['send-data-event',]);
const props = defineProps({
  closeDialog: {
    type: Function,
    required: true
  },
  selectedGlassData: {
    type: Array,
    required: false,
    default: () => []
  }
});
 
const setTrimming = () => {
  let json = "{"
  json+='"left_trim":"'+quicksetLeft.value+'",'
  json+='"up_trim":"'+quicksetTop.value+'",'
  json+='"right_trim":"'+quicksetRight.value+'",'
  json+='"down_trim":"'+quicksetBottom.value+'",'
  json+='"auto_fill_trim":"'+true+'",'
  json+='"quick_trim":"'+15+'"'
  json+="}"
 
  let configuration={
      json:json,
    }
 
  request.post(`/glassOptimize/saveConfiguration/修边/${username}`,configuration).then((res) => {
    if(res.code==200 && res.data===true){
      const dataToSend = {
        quicksetTop: quicksetTop.value,
        quicksetRight: quicksetRight.value,
        quicksetBottom: quicksetBottom.value,
        quicksetLeft: quicksetLeft.value,
        selectedItemsOnly: props.selectedGlassData && props.selectedGlassData.length > 0,
        selectedGlassData: props.selectedGlassData
      };
      emit('send-data-event', dataToSend);
      props.closeDialog(3);
    } else {
      ElMessage.warning(res.msg)
    }
  });
 
};
 
</script>
 
<template>
  <div id="box1">
    <div style="display: flex; margin-top: -20px; justify-content: center">
      <div class="square-container">
        <div class="square" @click="syncValues"></div>
        <el-input-number v-model="quicksetTop" class="top" placeholder="0"
                         controls-position="right" :step="0.1" :min="0"></el-input-number>
        <el-input-number v-model="quicksetRight" class="right" placeholder="0"
                         controls-position="right" :step="0.1" :min="0"></el-input-number>
        <el-input-number v-model="quicksetBottom" class="bottom" placeholder="0"
                         controls-position="right" :step="0.1" :min="0"></el-input-number>
        <el-input-number v-model="quicksetLeft" class="left" placeholder="0"
                         controls-position="right" :step="0.1" :min="0"></el-input-number>
      </div>
      <el-button type="primary" style="float: right; margin: -55px 0;" @click="setTrimming">应用</el-button>
    </div>
 
    <div>
      <span>鼠标点击蓝色图形区域可快速设置修边量(mm)</span>
      <el-input-number v-model="controlValue" class="quickset" placeholder="0"
                       controls-position="right" :step="1" :min="0"></el-input-number>
      <br>
      <span>查询原片时自动填充(mm)</span>
      <el-checkbox v-model="check" style="margin: 20px 0 0 117px;"/>
    </div>
  </div>
</template>
 
<style scoped>
#box1 {
  width: 100%;
  height: 100%;
  padding: 10px;
  border-radius: 5px;
}
 
.square-container {
  width: 300px;
  height: 300px;
  display: flex;
  position: relative;
  justify-content: center;
  align-items: center;
}
 
.square {
  width: 100px;
  height: 100px;
  background-color: #5cadfe;
}
 
.top,
.right,
.bottom,
.left {
  width: 100px;
  height: 50px;
  position: absolute;
}
 
.top {
  top: 45px;
  left: 50%;
  transform: translateX(-50%);
}
 
.right {
  top: 50%;
  right: -5px;
  transform: translateY(-50%);
}
 
.bottom {
  bottom: 45px;
  left: 50%;
  transform: translateX(-50%);
}
 
.left {
  top: 50%;
  left: -5px;
  transform: translateY(-50%);
}
 
.quickset {
  margin-left: 60px;
  width: 100px;
  height: 45px;
}
</style>