廖井涛
2024-03-04 2cf22385d45af4427b354e383243155ef35b70a5
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <!-- import CSS -->
  <script src="../js/main.js"></script>
  <style >
    .page-scroll {
      height: 100%;
    }
  
    .page-scroll .el-scrollbar__wrap {
      overflow-x: hidden;
    }
    img{  
    width: auto;  
    height: auto;  
    max-width: 100%;  
    max-height: 100%;     
}
  </style>
</head>
<body>
  <div id="app" >
    
    <el-container >
      
  
            <el-upload
              :limit="1"
              :on-change="changeFile"
              class="upload-demo"
              ref="upload"
              action="https://jsonplaceholder.typicode.com/posts/"
              :file-list="fileList"
              :auto-upload="false">
              <el-button slot="trigger" size="small" type="primary" >选取文件</el-button>
              <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过5m</div>
            </el-upload>
    
        
    </el-container>
      <img :src="ruleForm.route"  style="margin-right: 0;width: 1000px;height: 700px;background-color: aqua;" > 
  </div>
</body>
  
  <script >
    //import * as echarts from '../js/echarts.min.js';
    let app =new Vue({
      el: '#app',
      mixins:[mixin],
      data(){
        var checkNum = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('不能为空'));
        }
        setTimeout(() => {
         let reg = new RegExp(`^[0-9]{1,4}(\.[0-9]{0,2})?$`)
 
          if (!reg.test(value)) { 
            callback(new Error('请输入0.01-9999.99的数字'));
          }else {
              callback();
          }
          
        }, 1000);
      };
        var checkString = (rule, value, callback) => {
          if (!value) {
            return callback(new Error('不能为空'));
          }
          setTimeout(() => {
            if (value.length>255) { 
              callback(new Error('最大长度255'));
            }else {
                callback();
            }
          }, 1000);
        };
      var checkThickness = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('不能为空或者0'));
        }
        setTimeout(() => {
         let reg = new RegExp(`^[0-9]*[1-9][0-9]*$`)
 
          if (!reg.test(value)) { 
            callback(new Error('请输入正整数的厚度'));
          }else {
              callback();
          }
          
        }, 1000);
      };
      return {
        ruleForm: {
          produceid:'',
          width: '',
          height: '',
          thickness: '',
          color:'',
          optNum:'',
          creator:'',
          route:null
        },
        rules: {
          produceid: [
            { validator: checkString, trigger: 'blur' }
          ],
          height: [
            { validator: checkNum, trigger: 'blur' }
          ],
          width: [
            { validator: checkNum, trigger: 'blur' }
          ],
          thickness: [
            { validator: checkThickness, trigger: 'blur' }
          ],
          color: [
            { validator: checkString, trigger: 'blur' }
          ],
          optNum: [
            { validator: checkString, trigger: 'blur' }
          ],
          route: [
            { validator: checkString, trigger: 'blur' }
          ],
          
        },
        tableHead:[],
        produceData:[],
        showFlag:true,
        updateShowFlag:false,
        updateGlass:{
          id:''
        },
        optList:[],
        fileList:[],
        selectGlass:["","","","","","","",""]
 
 
      };
        
      },
      methods: {
        submitForm(formName) {
        this.$refs[formName].validate((valid) => {
            if (!valid) { 
              return false;
            }
            let sql="{call AXJ_a_produce_insert(?,?,?,?,?,?,?,?,?)}~"+JSON.stringify(this.ruleForm);
                  this.connects("新增产品",sql,1,1);
          });
        },
        resetForm(formName) {
          this.$refs[formName].resetFields();
        },
        showFlagFuc(){
          Object.keys(this.ruleForm).forEach((key) => (this.ruleForm[key] = ''));
          this.showFlag=!this.showFlag
          this.updateShowFlag=false;
        },
        updateRow(index,row){//修改产品数据显示
          this.showFlag=!this.showFlag
          this.updateShowFlag=true;
          let rowObj=row[index]
          this.ruleForm.produceid=rowObj["1_recipe_no"]
          this.ruleForm.width=rowObj["3_width"]
          this.ruleForm.height=rowObj["4_height"]
          this.ruleForm.thickness=rowObj["5_thickness"]
          this.ruleForm.color=rowObj["6_color"]
          this.ruleForm.optNum=rowObj["2_optfile_no"]
          this.ruleForm.creator=rowObj["7_recipe_maker"]
          this.ruleForm.route=rowObj["9_route"]
          this.updateGlass.id=rowObj["0_id"]
        },
        updateGlassSub(formName){
          this.$refs[formName].validate((valid) => {
            if (!valid) { 
              return false;
            }
            let updateGlassObj=this.ruleForm
            updateGlassObj.id=this.updateGlass.id
            let sql="{call AXJ_a_produce_update(?,?,?,?,?,?,?,?,?,?)}~"+JSON.stringify(updateGlassObj);
                  this.connects("产品修改",sql,1,1);
          });
          
        },
        changeFile(file){//添加文件触发生成base64文件
          const isJPG = file.raw.type === 'image/jpeg' || file.raw.type === 'image/png' ;
          const isLt2M = file.size / 1024 / 1024 < 5;
 
          if (!isJPG) {
            this.$message.error('上传头像图片只能是 JPG或者PNG 格式!')
            this.$refs.upload.clearFiles()
            return
          }
          if (!isLt2M) {
            this.$message.error('上传头像图片大小不能超过 5MB!')
            this.$refs.upload.clearFiles()
            return
          }
        
          return new Promise((resolve, reject) => {
          let reader = new FileReader();
          reader.readAsDataURL(file.raw);
          reader.onload = (e) => {
            resolve(e.target.result);
            console.log(e.target.result)
            this.updateShowFlag=true
            this.ruleForm.route=e.target.result;
          };
        });
        },
        selectSub:function(){
          let arrObj={}
          for(let i in this.selectGlass){
            arrObj[i]=this.selectGlass[i]
          }
          let sql="{call AXJ_a_produce_select(?,?,?,?,?,?,?,?,?)}~"+JSON.stringify(arrObj);
          loadAjxs('产品查询',sql,2,"produceData");
        }
      },
      computed:{
        
      },
      mounted() {
        // let sql="{call AXJ_a_produce_select_into()}";
        // let flag=2;
        // loadAjxs('产品初始查询',sql,flag,"produceData");
        
        // sql="{call AXJ_a_produceHeader_select()}";
        // loadAjxs('产品表头',sql,flag,"tableHead");
        
        // sql="{call AXJ_a_optFile_select()}";
        // loadAjxs('产品opt编码查询',sql,flag,"optList");
      },
 
    })
    
 
 
 
  </script>
</html>