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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
| <template>
| <el-dialog
| :title="title"
| :modal-append-to-body="false"
| :append-to-body="true"
| :close-on-click-modal="false"
| @close="close"
| width="60%"
| :visible.sync="visible"
| center
| >
| <div class="traceablility-body" v-if="!isShow">
| <div class="form">
| <div class="left">
| <div class="code">
| <div class="title">承诺达标合格证</div>
| <div style="width: 90%; margin: 0 auto; padding-top: 5px">
| <el-divider content-position="center">{{
| formLabelAlign.certificationCode == ""
| ? ""
| : formLabelAlign.certificationCode
| }}</el-divider>
| </div>
| <div style="width: 90%; margin: 0 auto">
| <div style="font-size: 14px; font-weight: 550">
| 我承诺对生产销售的食用农产品:
| </div>
| <div>
| <div style="width: 65%; float: left; font-size: 12px">
| <div style="margin-top: 5px">
| <input type="radio" v-model="radio" value="1" />
| 男不使用禁用农药兽药、停用兽药和非法添加物
| </div>
| <div style="margin-top: 3px">
| <input type="radio" v-model="radio" value="1" />
| 常规农药兽药残留不超标
| </div>
| <div style="margin-top: 3px">
| <input type="radio" v-model="radio" value="1" />
| 对承诺的真实性负责
| </div>
| <div
| style="font-size: 14px; font-weight: 550; margin-top: 5px"
| >
| 承诺依据:
| </div>
| <div style="width: 50%; float: left; margin-top: 5px">
| <input type="checkbox" v-model="wtjc" />
| 委托检测
| </div>
| <div style="margin-top: 5px">
| <input type="checkbox" v-model="zwjc" />
| 自我检测
| </div>
| <div style="width: 50%; float: left; margin-top: 5px">
| <input type="checkbox" v-model="nbjc" />
| 内部质量控制
| </div>
| <div style="margin-top: 5px">
| <input type="checkbox" v-model="zwcn" />
| 自我承诺
| </div>
| </div>
| <div>
| <img
| src="../../../public/img/code.png"
| style="width: 100px; height: 100px; margin-top: 10px"
| />
| </div>
| </div>
| </div>
| <div style="width: 90%; margin: 0 auto; padding-top: 40px">
| <el-divider></el-divider>
| </div>
| <div style="width: 90%; margin: 0 auto" class="form-data">
| <div class="input">
| <div class="left">产品名称:</div>
| <div class="rigth">{{ formLabelAlign.productName }}</div>
| </div>
| <div class="input">
| <div class="left">重量/数量:</div>
| <div class="rigth">
| {{
| formLabelAlign.weight == ""
| ? ""
| : formLabelAlign.weight + "公斤"
| }}
| </div>
| </div>
| <div class="input">
| <div class="left">产地:</div>
| <div class="rigth">{{ formLabelAlign.space }}</div>
| </div>
| <div class="input">
| <div class="left">联系方式:</div>
| <div class="rigth">{{ formLabelAlign.phone }}</div>
| </div>
| <div class="input">
| <div class="left">生产者盖章或签名:</div>
| <div class="rigth"></div>
| </div>
| <div class="input">
| <div class="left">开具日期:</div>
| <div class="rigth">{{ formLabelAlign.createTime }}</div>
| </div>
| <div class="input">
| <div class="left"></div>
| <div class="rigth"></div>
| </div>
| </div>
| </div>
| </div>
| <div class="right">
| <el-form
| :label-position="labelPosition"
| label-width="100px"
| :model="formLabelAlign"
| :rules="rules"
| ref="formLabelAlign"
| >
| <el-form-item label="农产品名称" prop="productName">
| <el-input maxlength="40" v-model="formLabelAlign.productName"></el-input>
| </el-form-item>
| <el-form-item label="开具日期" prop="createTime">
| <el-date-picker
| v-model="formLabelAlign.createTime"
| type="date"
| value-format="yyyy-MM-dd"
| placeholder="请选择开具日期"
| ></el-date-picker>
| </el-form-item>
| <el-form-item label="重量/数量" prop="weight">
| <el-input maxlength="9" v-model="formLabelAlign.weight"></el-input>
| </el-form-item>
| <el-form-item label="联系方式" prop="phone">
| <el-input maxlength="14" v-model="formLabelAlign.phone"></el-input>
| </el-form-item>
| <el-form-item label="产地" prop="space">
| <el-input maxlength="50" v-model="formLabelAlign.space"></el-input>
| </el-form-item>
| <el-form-item label="合格证编号" prop="certificationCode">
| <el-input maxlength="45" v-model="formLabelAlign.certificationCode"></el-input>
| </el-form-item>
| <el-form-item label="承诺依据" prop="according">
| <el-checkbox-group
| v-model="formLabelAlign.according"
| @change="changeCheckBox"
| >
| <el-checkbox
| label="委托检测"
| name="type"
| @change="wtChange"
| ></el-checkbox>
| <el-checkbox
| label="自我检测"
| name="type"
| @change="zwChange"
| ></el-checkbox>
| <el-checkbox
| label="内部质量控制"
| name="type"
| @change="nbChange"
| ></el-checkbox>
| <el-checkbox
| label="自我承诺"
| name="type"
| @change="cnChange"
| ></el-checkbox>
| </el-checkbox-group>
| </el-form-item>
| <el-form-item label="是否绑定溯源" prop="bind">
| <el-switch v-model="isBind" active-text="是" inactive-text="否" @change="OnAutoStart">
| </el-switch>
| </el-form-item>
| </el-form>
| </div>
| </div>
| </div>
| <div class="traceablility-table" v-if="isShow">
| <avue-crud
| :option="option"
| :table-loading="loading"
| :data="data"
| :page.sync="page"
| v-model="form"
| ref="crud"
| @search-change="searchChange"
| @search-reset="searchReset"
| @selection-change="selectionChange"
| @current-change="currentChange"
| @size-change="sizeChange"
| @refresh-change="refreshChange"
| @on-load="onLoad"
| ></avue-crud>
| </div>
| <div class="traceability-btn">
| <el-button type="primary" @click="next" v-if="isBind">{{
| tip
| }}</el-button>
| <!-- <el-button type="primary" @click="submit" v-if="isBtn">提 交</el-button> -->
| <el-button type="primary" @click="submit0" v-if="!isBind">提 交</el-button>
| </div>
| </el-dialog>
| </template>
|
| <script>
| import { mapState } from "vuex";
| import { save } from "@/api/traceability/traceability";
| import { getList } from "@/api/farmplant/recovery";
| import { getStrainList } from "@/api/farmplant/strain";
| import { getLandList,selectRecoveryLandList } from "@/api/land/land";
| export default {
| data() {
| return {
| selectionList: [],
| tip: "下一步",
| isShow: false,
| isBind: false,
| isBtn: 1,
| wtjc: false,
| zwjc: true,
| nbjc: false,
| zwcn: false,
| radio: "1",
| title: "创建溯源码",
| form: {},
| farm:{},
| formLabelAlign: {
| productName: "",
| createTime: "",
| according: ["自我检测"],
| weight: "",
| phone: "",
| space: "",
| certificationCode: "",
| code: "",
| },
| visible: false,
| rules: {
| productName: [
| { required: true, message: "请输入产品名称", trigger: ["blur","change"] },
| ],
| createTime: [
| {
| required: true,
| message: "请选择开具日期",
| trigger: "change",
| },
| ],
| weight: [
| {
| required: true,
| message: "请输入数量",
| trigger: "change",
| },
| ],
| phone: [
| {
| required: true,
| message: "请输入联系方式",
| trigger: "change",
| },
| ],
| according: [
| {
| type: "array",
| required: true,
| message: "请至少选择一个承诺依据",
| trigger: "change",
| },
| ],
| space: [{ required: true, message: "请输入产地", trigger: ["blur","change"], }],
| certificationCode: [
| { required: true, message: "请输入合格证编号", trigger:["blur","change"], },
| ],
| },
| page: {
| pageSize: 10,
| currentPage: 1,
| total: 0,
| },
| option: {
| tip: false,
| height: 400,
| editBtn: false,
| delBtn: false,
| viewBtn: false,
| addBtn: false,
| menu: false,
| menuAlign: "center",
| align: "center",
| selection: true,
| searchShow: true,
| searchMenuSpan: 6,
| column: [
| {
| label: "采收品种",
| prop: "strainName",
| },
| {
| label: "采收品种",
| prop: "strainId",
| search: true,
| searchSpan: 4,
| span: 12,
| type: "tree",
| hide:true,
| dicData: [],
| props: {
| label: "strainName",
| value: "id",
| },
| labelWidth: 145,
| rules: [
| {
| required: true,
| message: "请输入采收品种",
| trigger: ["blur","change"],
| },
| ],
| disabled: true,
| },
| {
| label: "采收地块",
| span: 12,
| labelWidth: 145,
| prop: "landId",
| type: "tree",
| search: true,
| searchSpan: 4,
| hide: true,
| dicData: [],
| props: {
| label: "landName",
| value: "id",
| },
| rules: [
| {
| required: true,
| message: "请选择地块",
| trigger: "click",
| },
| ],
| },
| {
| label: "地块",
| prop: "landName",
| display: false,
| },
| {
| label: "采收重量/公斤",
| prop: "weight",
| tip: "公斤",
| span: 12,
| labelWidth: 145,
| controls: false,
| type: "number",
| rules: [
| {
| required: true,
| message: "请输入采收重量 公斤",
| trigger: "click",
| },
| ],
| },
| {
| label: "采收时间",
| prop: "time",
| span: 12,
| labelWidth: 145,
| type: "datetime",
| format: "yyyy-MM-dd HH:mm",
| valueFormat: "yyyy-MM-dd HH:mm",
| rules: [
| {
| required: true,
| message: "请选择采收时间",
| trigger: "click",
| },
| ],
| },
| {
| label:"操作人",
| prop:"realName"
| },
| {
| label: "操作人",
| prop: "operator",
| type: "tree",
| dicData: [],
| hide:true,
| props: {
| label: "realName",
| value: "id",
| },
| span: 12,
| labelWidth: 145,
| rules: [
| {
| required: true,
| message: "请输入操作人",
| trigger: "click",
| },
| ],
| },
| ],
| },
| data: [],
| };
| },
| computed: {
| ...mapState({
| userInfo: (state) => state.user.userInfo,
| $farmId: state => state.user.$farmId,
| }),
| },
| methods: {
| //委托检测
| wtChange(data) {
| this.wtjc = data;
| },
| //自我检测
| zwChange(data) {
| this.zwjc = data;
| },
| //内部质量控制
| nbChange(data) {
| this.nbjc = data;
| },
| //自我承诺
| cnChange(data) {
| this.zwcn = data;
| },
| submit0(){
| if (this.isBind) {
| this.formLabelAlign["bind"] = "0";
| } else {
| this.formLabelAlign["bind"] = "1";
| }
| if(this.isBtn==1){
| this.submit();
| }
| if(this.isBtn==3){
| this.submits();
| }
| },
| //创建溯源码
| submit() {
| var that = this;
| that.formLabelAlign['tenantId'] = this.userInfo.tenant_id;
| that.formLabelAlign['deptId'] = this.$farmId;
| this.$refs["formLabelAlign"].validate((valid) => {
| if (valid) {
| that.formLabelAlign.createTime =
| that.formLabelAlign.createTime + " 00:00:00";
| var according = [];
| //承诺依据 数据格式转换
| that.formLabelAlign.according.forEach((item) => {
| if (item == "委托检测") {
| according.push(0);
| }
| if (item == "自我检测") {
| according.push(1);
| }
| if (item == "内部质量控制") {
| according.push(2);
| }
| if (item == "自我承诺") {
| according.push(3);
| }
| });
| that.formLabelAlign.according = according.join(",");
| //新增
| save(that.formLabelAlign).then(
| () => {
| that.$emit("refreshOnLoad");
| that.close();
| that.visible = false;
| that.isBtn = 1;
| that.$refs.formLabelAlign.resetFields();
| this.$message({
| type: "success",
| message: "操作成功!",
| });
| },
| (error) => {
| window.console.log(error);
| }
| );
| } else {
| console.log("error submit!!");
| return false;
| }
| });
| },
| //是否绑定溯源码绑定事件
| OnAutoStart(e){
| if(e){
| this.isBtn = 2;
| }else{
| this.isBtn = 1;
| }
| },
| //创建溯源码
| submits() {
| var that = this;
| if (this.selectionList.length > 0 && this.selectionList.length > 1) {
| this.$message.warning("只能绑定一个溯源");
| return;
| }
| if (this.selectionList.length ==1) {
| that.formLabelAlign['recoveryId'] = this.selectionList[0].id;
| that.formLabelAlign['bind'] = '0';
| }
| that.formLabelAlign['tenantId'] = this.userInfo.tenant_id;
| that.formLabelAlign['deptId'] = this.$farmId;
| //新增
| save(that.formLabelAlign).then(
| () => {
| that.$emit("refreshOnLoad");
| that.visible = false;
| that.isBtn = 1;
| that.close();
| this.$message({
| type: "success",
| message: "操作成功!",
| });
| },
| (error) => {
| window.console.log(error);
| }
| );
| },
| //关闭弹窗
| close() {
| //清除数据,状态回归
| this.isShow = false;
| this.isBind = false;
| this.isBtn = 1;
| this.wtjc = false;
| this.zwjc = true;
| this.nbjc = false;
| this.zwcn = false;
| this.formLabelAlign = {
| productName: "",
| createTime: "",
| according: ["自我检测"],
| weight: "",
| phone: "",
| space: "",
| certificationCode: "",
| code: "",
| };
| },
| //下一步
| next() {
| var that = this;
| this.$refs["formLabelAlign"].validate((valid) => {
| if (valid) {
| this.formLabelAlign["bind"] = "0";
| //设置时间
| that.formLabelAlign.createTime =
| that.formLabelAlign.createTime + " 00:00:00";
| var according = [];
| //承诺依据 数据格式转换
| that.formLabelAlign.according.forEach((item) => {
| if (item == "委托检测") {
| according.push(0);
| }
| if (item == "自我检测") {
| according.push(1);
| }
| if (item == "内部质量控制") {
| according.push(2);
| }
| if (item == "自我承诺") {
| according.push(3);
| }
| });
| that.formLabelAlign.according = according.join(",");
| //修改按钮状态
| this.isShow = true;
| this.isBind = false;
| this.isBtn = 3;
| //initFormData
| that.initFormData();
| } else {
| console.log("error submit!!");
| return false;
| }
| });
| },
| //初始化表格数据
| initFormData(){
| var that = this;
| // //获取农地数据
| // getLandList(this.userInfo.user_id).then((res)=>{
| // if(res.data.code==200){
| // var landIdcolumn = that.findObject(that.option.column,"landId");
| // that.landList = res.data.data;
| // landIdcolumn.dicData = res.data.data;
| // }
| // })
| //获取农地数据
| selectRecoveryLandList(this.$farmId).then((res)=>{
| if(res.data.code==200){
| var landIdcolumn = that.findObject(that.option.column,"landId");
| that.landList = res.data.data;
| landIdcolumn.dicData = res.data.data;
| }
| })
| //获取农产品数据
| getStrainList(0).then((res)=>{
| if(res.data.code==200){
| var strainId = that.findObject(that.option.column,"strainId");
| strainId.dicData = res.data.data;
| }
| })
| },
| //计算当前时间
| getNowTime() {
| var date = new Date();
| //年 getFullYear():四位数字返回年份
| var year = date.getFullYear(); //getFullYear()代替getYear()
| //月 getMonth():0 ~ 11
| var month = date.getMonth() + 1;
| //日 getDate():(1 ~ 31)
| var day = date.getDate();
| //赋值
| this.formLabelAlign.createTime =
| year + "-" + this.addZero(month) + "-" + this.addZero(day);
| },
| //小于10的拼接上0字符串
| addZero(s) {
| return s < 10 ? "0" + s : s;
| },
| //初始化
| init() {
| //计算当前时间
| this.getNowTime();
| this.visible = true;
| },
| searchReset() {
| this.query = {};
| this.onLoad(this.page);
| },
| searchChange(params, done) {
| this.query = params;
| this.page.currentPage = 1;
| this.onLoad(this.page, params);
| done();
| },
| selectionChange(list) {
| this.selectionList = list;
| },
| selectionClear() {
| this.selectionList = [];
| this.$refs.crud.toggleSelection();
| },
| currentChange(currentPage) {
| this.page.currentPage = currentPage;
| },
| sizeChange(pageSize) {
| this.page.pageSize = pageSize;
| },
| refreshChange() {
| this.onLoad(this.page, this.query);
| },
| onLoad(page, params = {}) {
| this.loading = true;
| params["farmId"] = this.$farmId
| getList(
| page.currentPage,
| page.pageSize,
| Object.assign(params, this.query)
| ).then((res) => {
| const data = res.data.data;
| this.page.total = data.total;
| this.data = data.records;
| this.loading = false;
| this.selectionClear();
| });
| },
| },
| };
| </script>
| <style lang="scss" scope>
| .traceablility-body {
| width: 100%;
|
| .form {
| display: flex;
| flex-direction: row;
| .left {
| width: 50%;
| .code {
| width: 60%;
| // height: 500px;
| margin-left: 20%;
| box-shadow: 5px 5px 5px 0 rgba(0, 0, 0, 0.05);
| -webkit-box-shadow: #d4d2d2 0px 0px 10px;
| -moz-box-shadow: #d4d2d2 0px 0px 10px;
|
| .title {
| padding-top: 15px;
| font-size: 24px;
| font-weight: 550;
| text-align: center;
| }
|
| .form-data {
| padding-top: -10px;
|
| .input {
| display: flex;
| flex-flow: row nowrap;
| justify-content: space-between;
| margin: 0 auto;
| padding-top: 15px;
|
| .rigth {
| font-size: 14px;
| font-weight: 550;
| }
| }
| }
| }
| }
| .right {
| width: 40%;
| padding-top: 10px;
| }
| }
| }
|
| .traceability-btn {
| text-align: center;
| margin-top: 30px;
| }
| </style>
|
|