licp
2024-12-20 b6d39af78f90623f808198ef9fbb156115aff565
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
<template>
  <div>
    <el-dialog v-loading="diaLoading" :close-on-click-modal="false"
               :close-on-press-escape="false"
               :visible.sync="formDia"
               title="三废处理信息"
               width="80%" @close="closeThreeWastesDia">
      <el-form ref="form" :model="form" :rules="rules" label-width="auto">
        <el-col :span="24">
          <el-form-item label="备注" prop="purposes">
            <el-input v-model="form.remark" clearable size="small"></el-input>
          </el-form-item>
        </el-col>
      </el-form>
      <div style="text-align: right;margin-bottom: 10px">
        <el-button size="small" type="primary" @click="addRow">添加</el-button>
        <el-button size="small" type="danger" @click="clearTable">清空</el-button>
      </div>
      <el-table :data="wastesDetailList" border height="300" style="width: 100%">
        <el-table-column align="center" label="序号" type="index" width="60" />
        <el-table-column header-align="center" label="接收人" prop="acceptor">
          <template slot-scope="{row}">
            <el-input v-model="row.acceptor" size="small"/>
          </template>
        </el-table-column>
        <el-table-column header-align="center" label="接收单位" prop="receivingUnit">
          <template slot-scope="{row}">
            <el-input v-model="row.receivingUnit" size="small"/>
          </template>
        </el-table-column>
        <el-table-column header-align="center" label="名称" prop="designation">
          <template slot-scope="{row}">
            <el-input v-model="row.designation" size="small"/>
          </template>
        </el-table-column>
        <el-table-column header-align="center" label="移交人" prop="transferPeople" width="180">
          <template slot-scope="{row}">
            <el-input v-model="row.transferPeople" size="small"/>
          </template>
        </el-table-column>
        <el-table-column header-align="center" label="体积" prop="volume" width="180">
          <template slot-scope="{row}">
            <el-input v-model="row.volume" size="small"/>
          </template>
        </el-table-column>
        <el-table-column header-align="center" label="送处理日期" prop="deliveryDate" width="180">
          <template slot-scope="{row}">
            <!-- <el-input v-model="row.deliveryDate" size="small"/> -->
            <el-date-picker
                value-format="yyyy-MM-dd"
                style="width: 100%"
                format="yyyy-MM-dd"
                size="small"
                v-model="row.deliveryDate"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
          </template>
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeThreeWastesDia">取 消</el-button>
        <el-button :loading="loading" type="primary" @click="handleEdit">提 交</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
export default {
  name: 'three-wastes-dialog',
  // import 引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    // 这里存放数据
    return {
      formDia: false,
      diaLoading: false,
      loading: false,
      form: {
        remark: '',
        wastesId: '',
      },
      rules: {
        remark: [{required: false, message: '请填写备注',trigger: 'blur'}],
      },
      wastesDetailList: [],
      operationType: '',
    };
  },
  mounted() {
 
  },
  // 方法集合
  methods: {
    // 打开弹框
    openDia (type, row) {
      this.formDia = true
      this.operationType = type
      if (type !== 'add') {
        this.searchInfo(row)
      }
    },
    // 查询详情
    searchInfo (row) {
      this.diaLoading = true
      this.$axios(this.$api.internalWastes.getInternalWastesOne + '?wastesId=' + row.wastesId).then(res => {
        this.diaLoading = false
        if (res.code === 201) return
        this.form = res.data
        this.wastesDetailList = this.form.wastesDetailList
      }).catch(err => {
        console.log(err)
        this.diaLoading = false
      })
    },
    // 提交弹框数据
    handleEdit () {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          if (this.wastesDetailList.length === 0) {
            this.$message.warning('请添加表格数据')
            return
          }
          this.loading = true
          const internalImplementDto = this.HaveJson(this.form)
          internalImplementDto.wastesDetailList = this.HaveJson(this.wastesDetailList)
          if (this.operationType === 'add') {
            this.$axios.post(this.$api.internalWastes.addInternalWastes, internalImplementDto, {
              headers: {
                "Content-Type": "application/json"
              },
              noQs: true
            }).then(res => {
              this.loading = false
              if (res.code === 201) return
              this.$message.success('操作成功')
              this.closeThreeWastesDia()
            }).catch(err => {
              console.log('err---', err);
              this.loading = false
            })
          } else if (this.operationType === 'edit') {
            this.$axios.post(this.$api.internalWastes.updateInternalWastes, internalImplementDto, {
              headers: {
                "Content-Type": "application/json"
              },
              noQs: true
            }).then(res => {
              this.loading = false
              if (res.code === 201) return
              this.$message.success('操作成功')
              this.closeThreeWastesDia()
            }).catch(err => {
              console.log('err---', err);
              this.loading = false
            })
          }
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    // 增加表格行数据
    addRow () {
      this.wastesDetailList.push({
        acceptor: '',
        receivingUnit: '',
        designation: '',
        transferPeople: '',
        volume: '',
        deliveryDate: '',
      })
    },
    // 清空表格数据
    clearTable () {
      this.wastesDetailList = []
    },
    closeThreeWastesDia () {
      this.$refs.form.resetFields();
      this.formDia = false
      this.$emit('closeThreeWastesDia')
    },
  }
};
</script>
 
<style scoped>
</style>