陈婷婷
2025-11-26 9dee5e1c040c5f17f3e49b86f7fc615af0068d95
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
<template>
  <div v-loading="formLoading" v-if="formShow">
    <div style=" margin-bottom: 10px; border-bottom: 1px solid #f6f6f6;">
      <el-button type="primary" @click="submitForm">保 存</el-button>
      <el-button type="primary" @click="close">退 出</el-button>
      <!-- <el-button @click="cancel">取 消</el-button> -->
    </div>
    <div style="margin: 10px; font-size: 28px; font-weight: bold; text-align: center;">新增/编辑用户信息</div>
    <el-form ref="form" :model="form" :rules="rules" label-width="128px">
      <el-tabs v-model="activeName" type="card">
        <el-tab-pane label="基本信息" name="first">
          <el-row>
            <el-col :span="6">
              <el-form-item label="角色" prop="HGroupName">
                <el-input v-model="form.HGroupName" placeholder="请输入角色" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
                <el-form-item label="级别" prop="HLev">
                    <el-select v-model="form.HLev" placeholder="请选择级别">
                        <el-option label="总经理级" value="总经理级"></el-option>
                        <el-option label="副总级" value="副总级"></el-option>
                        <el-option label="质量总监" value="质量总监"></el-option>
                        <el-option label="部长级" value="部长级"></el-option>
                        <el-option label="主管级" value="主管级"></el-option>
                        <el-option label="工程师" value="工程师"></el-option>
                        <el-option label="班组长级" value="班组长级"></el-option>
                        <el-option label="组员级" value="组员级"></el-option>
                    </el-select>
                </el-form-item>
            </el-col>
            <el-col :span="6">
                <el-form-item label="组织" prop="HUSEORGID">
                    <el-select v-model="form.HUSEORGID" placeholder="请选择组织">
                        <el-option v-for="(item, index) in organizationList" :key="index" :label="item.Name" :value="item.ID">
                        </el-option>
                    </el-select>
                </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item label="说明" prop="Explain">
              <el-input type="textarea" v-model="form.Explain" placeholder="请输入说明" />
            </el-form-item>
          </el-row>
        </el-tab-pane>
      </el-tabs>
      <el-table :data="editData" ref="editData" style="width: 100%" height="300" width="100%"
        @selection-change="handleTableZbEdit" border>
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column align="center" label="hmainid" prop="单据ID" />
        <el-table-column align="center" label="用户编码" prop="用户编码" />
        <el-table-column align="center" label="用户名称" prop="用户名称" />
        <el-table-column align="center" label="对应职员" prop="对应职员" />
        <el-table-column align="center" label="对应保管" prop="对应保管" />
        <el-table-column align="center" label="对应验收" prop="对应验收" />
        <el-table-column align="center" label="对应业务员" prop="对应业务员" />
        <el-table-column align="center" label="对应部门" prop="对应部门" />
        <el-table-column align="center" label="对应仓库" prop="对应仓库" />
        <el-table-column align="center" label="对应调入仓库" prop="对应调入仓库" />
        <el-table-column align="center" label="对应供应商" prop="对应供应商" />
        <el-table-column align="center" label="对应CLOUD账号" prop="对应CLOUD账号" />
        <el-table-column align="center" label="对应CLOUD组织" prop="对应CLOUD组织" />
      </el-table>
    </el-form>
  </div>
</template>
 
<script>
import axios from 'axios'
 
export default {
  name: 'Xt_UserGroupEdit',
  components: {},
  props: {
    OperationType: { type: Number, },
    linterid: {},
  },
  data() {
    return {
      baseURL: process.env.VUE_APP_BASE_API,        //后端接口前缀
 
      HModName: "Xt_UserListEdit",   
      formShow: false,                              //表单数据加载标记
      formLoading: true,                            //表单加载动画显示标记
      subDisabled: false,                           //保存按钮是否禁用(true禁用,false可用)
 
      rowHideShow: false,                           //列设置页面内容加载标记
      openRowHide: false,                           //列设置弹窗显示标记
      temp: undefined,                              //临时字段
      
      organizationList: JSON.parse(sessionStorage.getItem('organizationList')),//组织列表
 
      editData: [],                                 //子表数据
      checkedSysZb: [],                             //子表选中数据
      activeName: 'first',
    };
  },
  created() {
    this.getdata()
  },
  methods: {
    //#region 页面初始化
    getdata() {
      this.formShow = false
      this.formLoading = true
      this.getUserGroup()
      if ((this.OperationType == 1 && this.copyType != 1) || (!this.OperationType && !this.copyType)) {
        this.handleAdd()
      } else if (this.OperationType == 3 || this.copyType == 1) {
        this.$nextTick(() => {
          this.handleUpdate()
        })
      }
    },
 
    //#region 页面数据初始化
    reset() {
      this.form = {
        Czybm: '',
        Czymc: '',
        Czmm: '',
        Czyyz: '',
        Explain: '',
        HEmpID: 0,
        HEmpName: '',
        HK3UserName: '',
        HK3UserID: 0,
        HKeeper: '',
        HKeeperID: 0,
        HSecManager: '',
        HSecManagerID: 0,
        HSellManID: 0,
        HSellMan: '',
        HDept: '',
        HDeptID: 0,
        HWHName: '',
        HWhID: 0,
        HSCWHName: '',
        HSCWHID: 0,
        HSupName: '',
        HSupID: 0,
        HCloudUserName: '',
        HCloudUserPsd: '',
        HOrgID: sessionStorage["OrganizationID"] - 0,
        HProcID: 0,
        HProcName: '',
        HCusID: 0,
        HCusName: '',
        HGroupID: 0,
        HGroupName: '',
        HSourceID: 0,
        HSourceName: '',
        HCheckEmpID: 0,
        HCheckEmpName: '',
        HWorkCenterID: 0,
        HWorkCenterName: '',
        HICNumber: '',
        HDingDingUserID: 0,
      }
      this.editData = []
      this.editBtData = []
      this.ids = []
      this.subDisabled = false
      this.activeName = 'first'
      this.resetForm("form");
    },
    //#endregion
    
    //#region 新增页面初始化
    handleAdd() {
      this.reset()
      this.formShow = true
      this.formLoading = false
    },
    //#endregion
 
    //#region 编辑页面初始化
    handleUpdate() {
      this.reset()
      let rowHmainid = this.linterid
      axios.get(this.baseURL + "/Xt_User/EditUser", {
        params: { 'HID': rowHmainid }
      }).then(response => {
        if (response.data.code == 1) {
          var result = response.data
          var data = result.data.h_v_IF_UserList_Edit[0]
          this.form.Czybm = data.用户编码
          this.form.Czymc = data.用户名称
          this.form.Czmm = data.密码
          this.form.Czyyz = data.密码
          this.form.Explain = data.说明
          this.form.HEmpID = data.HEmpID
          this.form.HEmpName = data.对应职员
          this.form.HK3UserName = data.HK3UserID
          this.form.HK3UserID = data.HK3UserID
          this.form.HKeeper = data.HKeeper
          this.form.HKeeperID = data.HKeeperID
          this.form.HSecManager = data.HSecManager
          this.form.HSecManagerID = data.HSecManagerID
          this.form.HSellManID = data.HSellManID
          this.form.HSellMan = data.HSellMan
          this.form.HDept = data.HDept
          this.form.HDeptID = data.HDeptID
          this.form.HWHName = data.HWHName
          this.form.HWhID = data.HWhID
          this.form.HSCWHName = data.HSCWHName
          this.form.HSCWHID = data.HSCWHID
          this.form.HSupName = data.HSupName
          this.form.HSupID = data.HSupID
          this.form.HCloudUserName = data.对应CLOUD账号
          this.form.HCloudUserPsd = data.HCloudUserPsd
          this.form.HOrgID = data.HUSEORGID
          this.form.HProcID = data.HProcID
          this.form.HProcName = data.工序
          this.form.HCusID = data.HCusID
          this.form.HCusName = data.客户
          this.form.HGroupID = data.HGroupID
          this.form.HGroupName = data.班组
          this.form.HSourceID = data.HSourceID
          this.form.HSourceName = data.生产资源
          this.form.HCheckEmpID = data.HCheckEmpID
          this.form.HCheckEmpName = data.检验员
          this.form.HWorkCenterID = data.HWorkCenterID
          this.form.HWorkCenterName = data.工作中心
          this.form.HICNumber = data.IC卡号
          this.form.HDingDingUserID = data.钉钉ID号
          this.formShow = true
          this.get_DisplayUserGroupInfoList()
          this.formLoading = false
        }
      }).catch(error => {
        this.$modal.msgError("接口请求失败!");
      });
    },
    //#endregion
 
    //#endregion
    
    //#region 获取子表数据
    getUserGroup() {
      //角色列表
      axios.get(this.baseURL + '/Xt_UserGroup/list', {
        params: {
          sWhere: '',
        },
      }).then(response => {
        let data1 = response.data
        if (data1.code == 1) {
          this.editData = data1.data
        }
      }).catch(error => {
        this.$modal.msgError("接口请求失败!");
      });
    },
    //#endregion
    
 
    get_DisplayUserGroupInfoList() {
      var sWhere = "and UserId='" + this.linterid + "'";
      axios.get(this.baseURL + '/Xt_UserGroup/UserGroupInfoList', {
        params: {
          sWhere: sWhere,
        },
      }).then(response => {
        let data1 = response.data
        if (data1.count == 1) {
          if (data1.data.length > 0)
            if (this.editData.length > 0) {
              this.editData.forEach(row => {
                if (data1.data.some(selectedRow => selectedRow.GroupId === row.HGroupID)) {
                  this.$refs.editData.toggleRowSelection(row)
                }
              })
            }
        }
      }).catch(error => {
        this.$modal.msgError("接口请求失败!");
      });
    },
 
    //#region 获取参数_传递的JSON格式参数
    getUrlVars_JSON() {
      var datajson;
      var str = this.propsData; //获取链接中传递的参数
      var arr = str.substring(str.lastIndexOf("=") + 1);
      datajson = JSON.parse(decodeURI(arr));
      return datajson;
    },
    //#endregion
 
    
    //#region 组织下拉列表值变更监听
    organizationChange(val) {
      // let options=undefined
      //  this.form=this.organizationList.find(option => option.ID === val)?.Name || '';
    },
    //#endregion
 
    //#region 子表复选框选中数据监听事件
    handleTableZbEdit(selection) {
      this.checkedSysZb = selection
      // this.editData.forEach(row => {
      //   row.AuthorityHID = this.checkedSysZb.some(selectedRow => selectedRow.GroupId === row.HGroupID) ? 1 : 0;
      // });
    },
    //#endregion
 
    //#region 保存
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          var num = [];
          var Sav = ''
          if (this.OperationType == 1) {
            Sav = 'Add'
          } else if (this.OperationType == 3) {
            Sav = "Update"
          }
          for (var i = 0; i < this.checkedSysZb.length; i++) {
            num.push(this.checkedSysZb[i].HGroupID)
          }
          var sSubStr = num.toString() == "" ? "-1" : num.toString();
          var sMainStr = JSON.stringify(this.form) + ';' + Sav + ';' + sSubStr;
          axios({
            method: 'post',
            url: this.baseURL + "/Xt_User/SaveUser",
            data: {
              'msg': sMainStr
            },
          }).then(response => {
            if (response.data.count == 1) {
              this.formShow = false
              this.$emit('editClose', false)
              this.$modal.msgSuccess(response.data.Message);
            }
          }).catch(error => {
            this.$modal.msgError("接口请求失败!");
          });
        }
      });
    },
    //#endregion
 
    //#region 退出
    close() {
      this.reset()
      this.formShow = false
      this.$emit('editClose', false)
    },
    //#endregion
 
    //#region 列设置
    handleRowHide() {
      this.rowHideShow = true
      this.openRowHide = true
    },
    rowSetClose(val) {
      this.rowHideShow = false
      this.openRowHide = val
    },
    //#endregion
 
  }
};
</script>
<style>
.xsckdBox .el-date-editor.el-input {
  width: 100%;
}
</style>