zhouwx
6 天以前 1d66f43353524889999bbd9ac0b331c557ff98f7
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
<template>
  <div class="app-container">
    <div style="margin-bottom: 10px">
      <el-form style="display: flex;flex-wrap: wrap;">
        <el-form-item label="企业名称:" v-if="data.isAdmin" style="margin-left: 20px">
          <el-select
              v-model="data.queryParams.companyName"
              filterable
              remote
              @change="selectValue"
              reserve-keyword
              placeholder="请输入企业名称"
              remote-show-suffix
              :remote-method="getCompanyList"
              :loading="loadingCompany"
              style="width: 240px"
          >
            <el-option
                v-for="item in data.companyList"
                :key="item.id"
                :label="item.name"
                :value="item.name"
            />
          </el-select>
        </el-form-item>
        <el-form-item v-if="data.isAdmin">
          <el-button type="primary" style="margin-left: 30px" @click="searchClick">查询</el-button>
          <el-button plain @click="reset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="bottom">
      <div class="left">
        <span style="font-weight: 600;font-size: 24px">目录</span>
        <el-tree
            style="max-width: 600px;margin-top: 20px"
            :data="data.treeData"
            :props="data.defaultProps"
            :default-expand-all="true"
            :expand-on-click-node="false"
            @node-click="handleNodeClick"
        />
 
      </div>
      <div class="right">
        <el-form :model="data.form" size="default" ref="noticeRef" :rules="data.formRules" label-position="left" label-width="125px" >
          <el-form-item label="具体内容" prop="content" >
            <el-input v-model="data.form.content" :rows="4" type="textarea" />
          </el-form-item>
          <el-form-item label="标准分析" prop="analysis" >
            <el-input v-model="data.form.analysis" :rows="4" type="textarea" />
          </el-form-item>
          <el-form-item label="应准备材料" prop="dataList">
            <el-button type="primary" @click="openDataDialog('add',{})">新增</el-button>
          </el-form-item>
          <el-table style="margin:15px 0;width: 80%" :data="data.form.dataList" :border="true" >
            <el-table-column type="index" label="序号" width="80" align="center"></el-table-column>
            <el-table-column label="材料名称" prop="companyName" align="center"  />
            <el-table-column label="材料模板" prop="companyName" align="center"  />
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
              <template #default="scope">
                <el-button link type="primary"  @click="openDataDialog('edit',scope.row)" >编辑</el-button>
                <el-button link type="danger"  @click="handleDataDelete(scope.row)" >删除</el-button>
              </template>
            </el-table-column>
          </el-table>
          <el-form-item label="记录上传" prop="recordList">
            <el-button type="primary" @click="openRecordDialog('add',{})">新增</el-button>
          </el-form-item>
          <el-table style="margin-top: 15px;width: 80%" :data="data.form.recordList" :border="true" >
            <el-table-column type="index" label="序号" width="80" align="center"></el-table-column>
            <el-table-column label="记录名称" prop="companyName" align="center"  />
            <el-table-column label="记录模板" prop="companyName" align="center"  />
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
              <template #default="scope">
                <el-button link type="primary"  @click="openRecordDialog('edit',scope.row)" >编辑</el-button>
                <el-button link type="danger"  @click="handleRecordDelete(scope.row)" >删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
        <el-button type="primary" style="margin-top: 20px;text-align: right;float: right">保存</el-button>
      </div>
    </div>
    <dataDialog ref="dialogRef" @getList="getList"></dataDialog>
    <record-dialog ref="dialogRecordRef" @getList="getList"></record-dialog>
  </div>
</template>
<script setup>
import {getCurrentInstance, onMounted, reactive, ref, toRefs} from "vue";
import Cookies from "js-cookie";
import {ElMessage, ElMessageBox} from "element-plus";
import {getCompany} from "@/api/onlineEducation/company";
import {getToken} from "@/utils/auth";
import {delPic} from "@/api/onlineEducation/banner";
import dataDialog from "./components/dataDialog.vue"
import recordDialog from "./components/recordDialog.vue"
import {delSysClause} from "@/api/staffManage/staff";
 
const { proxy } = getCurrentInstance();
const loading = ref(false);
const noticeRef = ref();
const dialogRef = ref();
const dialogRecordRef = ref();
const loadingCompany = ref(false)
const choosedData = ref([])
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    companyId: null,
  },
  form: {
    id: '',
    companyId: null,
    content: '',
    analysis: '',
    dataList: [],
    recordList: []
  },
  formRules: {
    content: [{ required: true, message: '请输入具体内容', trigger: 'blur' }],
    analysis: [{ required: true, message: '请输入标准分析', trigger: 'blur' }],
    dataList: [{ required: true, message: '请输入标准分析', trigger: 'blur' }],
    recordList: [{ required: true, message: '请输入标准分析', trigger: 'blur' }]
  },
  companyList: [],
  isAdmin: false,
  defaultProps: {
    children: 'children',
    label: 'label',
  },
  treeData: [
    {
      label: '1范围',
      children: [
        {
          label: '1.1规范范围管理',
          children: [
            {
              label: 'Level three 1-1-1',
              children: [
                {
                  label: 'Level three 1-1-1',
                  children: [
                    {
                      label: 'Level three 1-1-1',
                    },
                  ],
                },
              ],
            },
          ],
        },
        {
          label: '1.2收集需求',
        },
        {
          label: '1.3定义范围',
        },
      ],
    },
  ],
  dataVisible: false,
  dataTitle: '',
  uploadUrl: import.meta.env.VITE_APP_BASE_API + '/system/common/uploadFile',
  header: {
    Authorization: getToken()
  },
  fileLimit: 1,
  fileDataList: []
 
});
const dataList = ref([]);
const total = ref(0);
 
const { queryParams } = toRefs(data);
 
onMounted(async () => {
  const userInfo = JSON.parse(Cookies.get('userInfo'))
  console.log("userInfo",userInfo)
  data.isAdmin = userInfo.userType === 0;
  if(data.isAdmin){
    await getCompanyList()
    data.queryParams.companyId = data.companyList[0].id
    data.queryParams.companyName = data.companyList[0].name
    data.form.companyId = data.companyList[0].id
  }else {
    data.queryParams.companyId = userInfo.companyId
  }
  await getList();
})
const getList = async () => {
  loading.value = true;
  // const res = await getBasic(data.queryParams);
  // if(res.code === 200){
  //   dataList.value = res.data.list
  //   total.value = res.data.total
  // }else{
  //   ElMessage.warning(res.message)
  // }
  loading.value = false;
 
}
const getCompanyList = async (val)=>{
  if(val){
    loadingCompany.value = true;
    const queryParams = {
      name: val
    }
    const res = await getCompany(queryParams)
    if (res.code == 200) {
      loadingCompany.value = false;
      data.companyList = res.data.list
 
    } else {
      ElMessage.warning(res.message)
    }
  }else {
    loadingCompany.value = true;
    const queryParams = {
      pageSize: 10,
      pageNum: 1,
    }
    const res = await getCompany(queryParams)
    if (res.code == 200) {
      loadingCompany.value = false;
      data.companyList = res.data.list
 
    } else {
      ElMessage.warning(res.message)
    }
  }
}
const selectValue = (val) => {
  data.companyList.forEach(item => {
    if(item.name === val){
      data.queryParams.companyId = item.id
    }
  })
}
const searchClick = () => {
  getList();
}
function reset() {
  data.queryParams = {
    companyId: '',
    pageNum: 1,
    pageSize: 10,
  }
  choosedData.value = []
  data.companyList = [];
  getList();
  getCompanyList()
}
const handleNodeClick = (val) => {
  console.log('node',val)
}
const openDataDialog = (type, value) => {
  dialogRef.value.openDialog(type, value, data.queryParams.companyId, data.isAdmin, data.companyList);
}
const openRecordDialog = (type, value) => {
  dialogRecordRef.value.openDialog(type, value, data.queryParams.companyId, data.isAdmin, data.companyList);
}
 
const handleDataDelete = (val) => {
  ElMessageBox.confirm(
      '确定删除此条数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const res = await delSysClause({id: val.id})
        if(res.code == 200){
          ElMessage.success('数据删除成功')
          await getList()
        }else{
          ElMessage.warning(res.message)
        }
      })
}
 
const handleRecordDelete = (val) => {
  ElMessageBox.confirm(
      '确定删除此条数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const res = await delSysClause({id: val.id})
        if(res.code == 200){
          ElMessage.success('数据删除成功')
          await getList()
        }else{
          ElMessage.warning(res.message)
        }
      })
}
</script>
 
<style scoped lang="scss">
.app-container{
  .bottom{
    display: flex;
    width: auto;
    height: auto;
    border: 1px solid #c3c3c3;
    margin: 20px;
 
    .left{
      border-right: 1px solid darkgray;
      display: flex;
      min-width: 240px;
      margin: 20px 20px 20px 50px;
      flex-direction: column;
      :deep(.el-tree){
        background: none;
      }
 
    }
    .right{
      margin: 20px 20px 20px 10px;
      flex: 1;
      :deep(.el-form-item__label){
        font-weight: 600;font-size: 20px
      }
 
    }
  }
 
}
</style>