祖安之光
3 天以前 92ba3755f447d1c4f12b476d44552decc5ed3b62
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
<template>
  <div class="app-container">
    <div style="display: flex;justify-content: space-between">
      <el-form :inline="true" style="display: flex;align-items: center;flex-wrap: wrap;" >
<!--        <el-form-item>-->
<!--          <el-button-->
<!--              type="primary"-->
<!--              plain-->
<!--              icon="Plus"-->
<!--              @click="openDialog('add',{})"-->
<!--          >新增</el-button>-->
<!--        </el-form-item>-->
        <el-form-item v-if="isAdmin" label="企业:" >
          <el-select v-model="data.queryParams.companyId" placeholder="请选择" clearable>
            <el-option
                v-for="item in companyList"
                :key="item.id"
                :label="item.name"
                :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item >
          <el-button v-if="isAdmin" type="primary" @click="getList">查询</el-button>
          <el-button v-if="isAdmin" type="primary" plain @click="reset">重置</el-button>
          <el-button type="primary" @click="addFile">生成质量手册</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 表格数据 -->
    <el-table v-loading="loading" :data="dataList" :border="true">
      <el-table-column label="序号" type="index" align="center" width="80"/>
      <el-table-column label="质量手册" prop="fileName" align="center">
        <template #default="scope">
          <el-button link type="primary" @click="initFile(scope.row.companyName)">{{scope.row.companyName + scope.row.qualityName + '.docx'}}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
<!--          <el-button link type="primary" @click="openDialog('edit',scope.row)">编辑</el-button>-->
          <el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
 
    <pagination
        v-show="total > 0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />
 
    <edit-dialog ref="dialogRef" @getList=getList></edit-dialog>
  </div>
</template>
 
<script setup>
import {getCurrentInstance, onMounted, onUnmounted, reactive, ref, toRefs} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import {delCompany, getCompany} from "@/api/onlineEducation/company";
import {delUser, getUser} from "@/api/onlineEducation/user";
import Cookies from "js-cookie";
import editDialog from './components/editDialog.vue'
import {generateWordDocument} from './components/exportDoc.js'
 
 
import {
  addIndustryTemp,
  delIndustryTemp,
  getIndustryTemp,
} from "@/api/staffManage/staff";
import useUserStore from "@/store/modules/user";
import {
  addStandardQuality,
  delStandardQuality,
  getStandardDetail,
  getStandardQuality
} from "@/api/standardSys/standardSys";
import {getBasic} from "@/api/companyInfo/basicInfo";
import {getCom} from "@/api/companyInfo/overview";
 
const userStore = useUserStore()
const { proxy } = getCurrentInstance();
const loading = ref(false);
const dialogRef = ref();
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    companyId: null
  },
  total: 0,
  dataList: [],
  companyList: [],
  isAdmin: false,
  companyInfo: {
    summaries: '',
    policies: '',
    deptList: [],
    duties: [],
    temps: []
  },
  caluseList: [
    {clauseNum: '4', content: '组织环境'},
    {clauseNum: '4.1', content: '理解组织及其环境',manage: true,represent: false},
    {clauseNum: '4.2', content: '理解相关方的需求和期望',manage: true,represent: false},
    {clauseNum: '4.3', content: '确定质量管理体系的范围',manage: false,represent: true},
    {clauseNum: '4.4', content: '质量管理体系及其过程',manage: false,represent: true},
    {clauseNum: '5', content: '领导作用'},
    {clauseNum: '5.1', content: '领导作用和承诺',manage: true,represent: false},
    {clauseNum: '5.2', content: '方针',manage: true,represent: false},
    {clauseNum: '5.3', content: '组织内的角色、职责和权限',manage: true,represent: false},
    {clauseNum: '6', content: ''},
    {clauseNum: '6.1', content: '应对风险和机遇的措施',manage: true,represent: false},
    {clauseNum: '6.2', content: '质量目标及其实现的策划',manage: false,represent: true},
    {clauseNum: '6.3', content: '变更的策划',manage: false,represent: true},
    {clauseNum: '7', content: '支持'},
    {clauseNum: '7.1', content: '资源',manage: true,represent: false},
    {clauseNum: '7.1.1', content: '总则',manage: true,represent: false},
    {clauseNum: '7.1.2', content: '人员',manage: true,represent: false},
    {clauseNum: '7.1.3', content: '基础设施',manage: false,represent: true},
    {clauseNum: '7.1.4', content: '过程运行环境',manage: false,represent: true},
    {clauseNum: '7.1.5', content: '监视和测量资源',manage: false,represent: true},
    {clauseNum: '7.1.6', content: '组织的知识',manage: false,represent: true}
  ]
});
 
const { queryParams, total, dataList,companyList, isAdmin } = toRefs(data);
const userInfo = ref()
onMounted(async ()=>{
  if(userStore.roles.includes('admin')){
    data.isAdmin = true
    await getCompanyList()
  }else{
    data.isAdmin = false
    data.queryParams.companyId = userStore.companyId
  }
  await getList()
})
 
onUnmounted(()=>{
 
})
 
const getList = async () => {
  loading.value = true
  const res = await getStandardQuality(data.queryParams)
  if(res.code == 200){
    data.dataList = res.data.data || []
    data.total = res.data.total
  }else{
    ElMessage.warning(res.message)
  }
  loading.value = false
}
 
const addFile = async ()=>{
  let params={}
  if(data.queryParams.companyId){
    params = {
      qualityName: '质量手册',
      companyId: data.queryParams.companyId
    }
  }else{
    ElMessage.warning('请先选择对应的企业')
    return
  }
  const res = await addStandardQuality(params)
  if(res.code == 200){
    ElMessage.success(res.message)
    await getList()
  }else{
    ElMessage.warning(res.message)
  }
}
 
const getCompanyList = async ()=>{
  const queryParams = {
    pageNum: 1,
    pageSize: 999
  }
  const res = await getCompany(queryParams)
  if (res.code == 200) {
    data.companyList = res.data.list?res.data.list:[]
    // data.queryParams.companyId = data.companyList[0].id
  } else {
    ElMessage.warning(res.message)
  }
}
 
const getInfo = async () => {
  loading.value = true;
  if(!data.queryParams.companyId){
    ElMessage.warning('请选择企业')
  }
  const res = await getStandardDetail({companyId: data.queryParams.companyId});
  if(res.code === 200){
    data.companyInfo.summaries = res.data.companySummaries[0].companySummary
    data.companyInfo.policies = res.data.companyQualityPolicies[0].policy
    data.companyInfo.deptList = res.data.treeSelects
    data.companyInfo.duties = transformDuties(res.data.sysFunctionalDistributions)
    data.companyInfo.temps = res.data.companyIndustryTemplates?.map((item,index)=>{
      return {
        index: index + 1,
        templateName: item.templateName
      }
    })
  }else{
    ElMessage.warning(res.message)
  }
  loading.value = false;
 
}
 
const transformDuties=(duties)=>{
  let tableData = []
  for(let item of duties){
    const index = tableData.findIndex(i=>i.deptId == item.deptId)
    if(index == -1){
      const obj = {
        deptName: item.deptName,
        deptId: item.deptId
      }
      obj[item.clauseNum] = item.chooseLab==1?'●':'○'
      tableData.push(obj)
    }else{
      tableData[index][item.clauseNum] = item.chooseLab==1?'●':'○'
    }
  }
  console.log(tableData,'table1')
  tableData = tableData.map(j=>{
    for(let i of data.caluseList){
      if(!j.hasOwnProperty(i.clauseNum)){
        j[i.clauseNum] = '○'
      }
    }
    return j
  })
  console.log(tableData,'table2')
  return tableData
}
 
const initFile = async (name) => {
  await getInfo()
  const templatePath = '/qualityFile.docx'
  try {
    await generateWordDocument(
        templatePath,
        data.companyInfo,
        name+'质量手册.docx'
    );
    ElMessage.success('手册导出成功!');
  } catch (error) {
    console.error('导出失败:', error);
    ElMessage.warning('手册导出失败');
  }
}
 
const openDialog = (type, value) => {
  dialogRef.value.openDialog(type, value, data.queryParams.companyId, data.isAdmin, data.companyList);
}
 
/** 重置新增的表单以及其他数据  */
const reset= async()=> {
  data.queryParams = {
    pageNum: 1,
    pageSize: 10,
    companyId: null
  }
  await getCompanyList()
  await getList()
}
const handleDelete = (val) => {
  ElMessageBox.confirm(
      '确定删除此条数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const res = await delStandardQuality({standardizedQualityId: val.id})
        if(res.code == 200){
          ElMessage.success('数据删除成功')
          await getList()
        }else{
          ElMessage.warning(res.message)
        }
      })
}
 
</script>