riskV2.vue 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  1. <template>
  2. <el-dialog
  3. v-loading="loading"
  4. :title="title"
  5. :visible.sync="dialogVisible"
  6. :close-on-click-modal="false"
  7. :close-on-press-escape="false"
  8. :show-close="false"
  9. append-to-body
  10. fullscreen
  11. class="dialog paper-detail-dialog"
  12. top="0"
  13. >
  14. <div slot="title" class="dialog-title">
  15. <span class="dialogtitle">{{ title }}</span>
  16. <div>
  17. <ibps-toolbar :actions="toolbars" @action-event="handleActionEvent" />
  18. </div>
  19. </div>
  20. <div class="container">
  21. <div class="left" :style="{width:initWidth}">
  22. <el-descriptions title="" direction="vertical" :column="5" border size="mini">
  23. <el-descriptions-item label="年度" class="aaaa">
  24. <span class="required-star">*</span>
  25. <el-date-picker
  26. v-model="infoFxssbData.nian_du_"
  27. type="year"
  28. placeholder="选择年"
  29. :disabled="readonly"
  30. value-format="yyyy"
  31. size="mini"
  32. />
  33. </el-descriptions-item>
  34. <el-descriptions-item label="编制部门">
  35. <div style="display:flex">
  36. <span class="required-star">*</span>
  37. <ibps-user-selector
  38. type="position"
  39. :value="infoFxssbData.bian_zhi_bu_men_"
  40. readonly-text="text"
  41. :disabled="readonly"
  42. :multiple="false"
  43. size="mini"
  44. style="width:100%"
  45. :filter="filter"
  46. filterable
  47. />
  48. </div>
  49. </el-descriptions-item>
  50. <el-descriptions-item label="编制人">
  51. <ibps-user-selector
  52. type="user"
  53. :value="infoFxssbData.bian_zhi_ren_"
  54. readonly-text="text"
  55. :disabled="true"
  56. :multiple="true"
  57. size="mini"
  58. />
  59. </el-descriptions-item>
  60. <el-descriptions-item label="编制时间">
  61. <span class="required-star">*</span>
  62. <el-date-picker
  63. v-model="infoFxssbData.bian_zhi_shi_jian"
  64. type="datetime"
  65. placeholder="选择日期时间"
  66. :disabled="readonly"
  67. value-format="yyyy-MM-dd HH:mm:ss"
  68. size="mini"
  69. />
  70. </el-descriptions-item>
  71. <el-descriptions-item label="评估编号">
  72. {{ infoFxssbData.ji_hua_bian_hao_ }}
  73. </el-descriptions-item>
  74. <el-descriptions-item label="组长">
  75. <ibps-user-selector
  76. type="user"
  77. :value="infoFxssbData.zu_chang_id_"
  78. readonly-text="text"
  79. :disabled="true"
  80. :multiple="true"
  81. size="mini"
  82. :filter="filter"
  83. filterable
  84. />
  85. </el-descriptions-item>
  86. <el-descriptions-item label="评估开始时间">
  87. <span class="required-star">*</span>
  88. <el-date-picker
  89. v-model="infoFxssbData.kai_shi_ri_qi_"
  90. type="date"
  91. placeholder="选择日期"
  92. :disabled="readonly"
  93. value-format="yyyy-MM-dd"
  94. size="mini"
  95. />
  96. </el-descriptions-item>
  97. <el-descriptions-item label="评估结束时间">
  98. <span class="required-star">*</span>
  99. <el-date-picker
  100. v-model="infoFxssbData.jie_shu_ri_qi_"
  101. type="date"
  102. placeholder="选择日期"
  103. :disabled="readonly"
  104. value-format="yyyy-MM-dd"
  105. size="mini"
  106. />
  107. </el-descriptions-item>
  108. <el-descriptions-item label="报告完成时间">
  109. <span class="required-star">*</span>
  110. <el-date-picker
  111. v-model="infoFxssbData.bao_gao_shi_jian_"
  112. type="date"
  113. placeholder="选择日期"
  114. :disabled="readonly"
  115. value-format="yyyy-MM-dd"
  116. size="mini"
  117. />
  118. </el-descriptions-item>
  119. <el-descriptions-item label="风险类型">
  120. <div>
  121. <el-radio v-model="infoFxssbData.feng_xian_lei_xin" label="质量" size="mini" :disabled="readonly">质量</el-radio>
  122. <el-radio v-model="infoFxssbData.feng_xian_lei_xin" label="安全" size="mini" :disabled="readonly">安全</el-radio>
  123. </div>
  124. </el-descriptions-item>
  125. <el-descriptions-item label="时机" :span="1">
  126. <el-select v-model="infoFxssbData.shi_ji_" :disabled="readonly" placeholder="请选择" size="mini">
  127. <el-option
  128. v-for="item in ['定期评估','新增活动','不良事件','程序变化','业务变化']"
  129. :key="item"
  130. :label="item"
  131. :value="item"
  132. />
  133. </el-select>
  134. </el-descriptions-item>
  135. <el-descriptions-item label="范围" :span="2">
  136. <el-input v-model="infoFxssbData.fan_wei_" :disabled="readonly" size="mini" />
  137. </el-descriptions-item>
  138. <el-descriptions-item label="方法" :span="2">
  139. <el-input v-model="infoFxssbData.fang_fa_" :disabled="readonly" size="mini" />
  140. </el-descriptions-item>
  141. <el-descriptions-item label="目的" :span="5">
  142. <el-input v-model="infoFxssbData.mu_di_" :disabled="readonly" size="mini" />
  143. </el-descriptions-item>
  144. <el-descriptions-item label="依据文件" :span="5">
  145. <!-- 模版弹窗 -->
  146. <ibps-custom-dialog
  147. v-if="!readonly"
  148. v-model="infoFxssbData.yi_ju_wen_jian_id"
  149. template-key="nsyjwjxz"
  150. multiple
  151. type="dialog"
  152. class="custom-dialog"
  153. placeholder="请选择依据文件"
  154. size="mini"
  155. icon="el-icon-search"
  156. />
  157. <pre style="margin:0">{{ infoFxssbData.yi_ju_wen_jian_ }}</pre>
  158. </el-descriptions-item>
  159. <el-descriptions-item label="首次会议时间" :span="1">
  160. <!-- <span class="required-star">*</span> -->
  161. <el-date-picker
  162. v-model="infoFxssbData.hui_yi_shi_jian_"
  163. type="datetime"
  164. placeholder="选择日期时间"
  165. default-time="12:00:00"
  166. :disabled="readonly"
  167. value-format="yyyy-MM-dd HH:mm"
  168. size="mini"
  169. />
  170. </el-descriptions-item>
  171. <el-descriptions-item label="参会人员" :span="4">
  172. <div style="display:flex">
  173. <!-- <span class="required-star">*</span> -->
  174. <ibps-user-selector
  175. v-model="infoFxssbData.can_hui_ren_yuan_"
  176. style="width:100%"
  177. type="user"
  178. readonly-text="text"
  179. :disabled="readonly"
  180. :multiple="true"
  181. size="mini"
  182. :filter="filter"
  183. filterable
  184. />
  185. </div>
  186. </el-descriptions-item>
  187. <el-descriptions-item label="会议附件" :span="5">
  188. <ibps-attachment
  189. v-model="infoFxssbData.hui_yi_fu_jian_"
  190. :download="true"
  191. multiple
  192. accept="*"
  193. :readonly="readonly"
  194. size="mini"
  195. />
  196. </el-descriptions-item>
  197. <el-descriptions-item label="事务说明 " :span="5">
  198. <el-input v-model="infoFxssbData.shi_wu_shuo_ming_" :disabled="readonly" size="mini" /></el-descriptions-item>
  199. <el-descriptions-item label="评估人员 " :span="5">
  200. <div style="display:flex">
  201. <span class="required-star">*</span>
  202. <ibps-user-selector
  203. v-model="infoFxssbData.ping_gu_ren_yuan_"
  204. type="user"
  205. style="width:100%"
  206. readonly-text="text"
  207. :disabled="readonly"
  208. :multiple="true"
  209. size="mini"
  210. :filter="filter"
  211. filterable
  212. />
  213. </div>
  214. </el-descriptions-item>
  215. </el-descriptions>
  216. <div v-if="isEdit" style="margin-top:20px">
  217. <el-alert
  218. title="根据评估人员选定的风险识别项给每个措施制定人推送风险改进流程"
  219. type="success"
  220. :closable="false"
  221. />
  222. <RiskPeopleTable ref="RiskPeopleTableRef" :params="params" :people-ids="infoFxssbData.ping_gu_ren_yuan_" @goBack="goRefresh" />
  223. </div>
  224. </div>
  225. </div>
  226. <!-- <data-template-formrender-dialog
  227. :visible="DialogVisible"
  228. form-key="fxbg"
  229. :pk-value="pkValue"
  230. :readonly="readonly"
  231. @close="visible => DialogVisible = visible"
  232. /> -->
  233. <RiskDetail ref="RiskDetailRef" @close="goRefresh" />
  234. </el-dialog>
  235. </template>
  236. <script>
  237. import dayjs from 'dayjs'
  238. import RiskPeopleTable from './riskPeopleTable.vue'
  239. import ibpsUserSelector from '@/business/platform/org/selector'
  240. import RiskDetail from './riskDetail.vue'
  241. import IbpsAttachment from '@/business/platform/file/attachment/selector'
  242. import DataFormrender from '@/business/platform/data/templaterender/form'
  243. import DataTemplateFormrenderDialog from '@/business/platform/data/templaterender/form/dialog.vue'
  244. export default {
  245. components: {
  246. RiskDetail,
  247. RiskPeopleTable,
  248. ibpsUserSelector,
  249. IbpsAttachment,
  250. DataFormrender,
  251. DataTemplateFormrenderDialog,
  252. IbpsCustomDialog: () => import('@/business/platform/data/templaterender/custom-dialog')
  253. },
  254. props: {
  255. params: {
  256. type: Object,
  257. default: function () {
  258. return {}
  259. }
  260. }
  261. },
  262. data () {
  263. const { userId, position, level } = this.$store.getters
  264. return {
  265. filter: [{
  266. descVal: '2',
  267. includeSub: true,
  268. old: 'position',
  269. partyId: this.$store.getters.userInfo.employee.positions,
  270. partyName: '',
  271. scriptContent: '',
  272. type: 'user',
  273. userType: 'position'
  274. }],
  275. isFirst: true,
  276. userId: userId,
  277. position: position,
  278. level: level.second || level.first,
  279. pkValue: '',
  280. readonly: true,
  281. DialogVisible: false,
  282. loading: false,
  283. dialogVisible: true,
  284. title: '风险评估与措施',
  285. toolbars: [
  286. { key: 'refresh', label: '刷新', hidden: () => { return !this.isZuZhang || !this.isEdit || this.isFinished } },
  287. { key: 'save', label: '保存', hidden: () => { return !this.isZuZhang || this.isFinished } },
  288. // { key: 'sendMsg', label: '提醒评估人', icon: 'el-icon-bell', hidden: () => { return !this.isZuZhang || !this.isEdit || this.isFinished } },
  289. { key: 'peizhifengxian', label: '更新风险库', type: 'info', icon: 'el-icon-setting', hidden: () => { return !this.isZuZhang || !this.isEdit } },
  290. { key: 'submit', label: '提交', icon: 'el-icon-finished', hidden: () => { return !this.isZuZhang || !this.isEdit || this.isFinished } },
  291. { key: 'cancel', label: '退出', type: 'danger', icon: 'ibps-icon-close' }
  292. ],
  293. infoFxssbData: {
  294. nian_du_: '',
  295. bian_zhi_bu_men_: '',
  296. bian_zhi_ren_: '',
  297. bian_zhi_shi_jian: '',
  298. zu_chang_: '',
  299. zu_chang_id_: '',
  300. kai_shi_ri_qi_: '',
  301. jie_shu_ri_qi_: '',
  302. bao_gao_shi_jian_: '',
  303. feng_xian_lei_xin: '',
  304. shi_ji_: '',
  305. fan_wei_: '',
  306. fang_fa_: '',
  307. mu_di_: '',
  308. yi_ju_wen_jian_id: '',
  309. yi_ju_wen_jian_: '',
  310. hui_yi_shi_jian_: '',
  311. can_hui_ren_yuan_: '',
  312. hui_yi_fu_jian_: '',
  313. shi_wu_shuo_ming_: '',
  314. ping_gu_ren_yuan_: '',
  315. ji_hua_bian_hao_: ''
  316. },
  317. initWidth: '1280px',
  318. isEdit: false,
  319. isPingGuRen: false,
  320. isZuZhang: true,
  321. isFinished: false,
  322. preParams: {},
  323. Ids: []
  324. }
  325. },
  326. watch: {
  327. 'infoFxssbData.yi_ju_wen_jian_id': {
  328. handler (val) {
  329. const sql = `select * from yijuwenjianxuanze where id_ in ('${val.replace(/,/g, "','")}') order by id_`
  330. this.$common.request('sql', sql).then(response => {
  331. const conts = response.variables.data
  332. let fileName = ''
  333. let num = 1
  334. conts.forEach((item, index) => {
  335. fileName += `${num}、${item.name_}\n`
  336. num = num + 1
  337. })
  338. this.infoFxssbData.yi_ju_wen_jian_ = fileName
  339. })
  340. },
  341. immediate: true
  342. },
  343. 'infoFxssbData.zu_chang_id_': {
  344. handler (val) {
  345. if (val) {
  346. const userList = this.$store.getters.userList
  347. const bianzhiUserid = userList.find(i => i.userId === val)
  348. if (bianzhiUserid) {
  349. this.infoFxssbData.zu_chang_ = bianzhiUserid.userName
  350. }
  351. }
  352. }
  353. },
  354. 'infoFxssbData.feng_xian_lei_xin': {
  355. handler (val) {
  356. if (val) {
  357. if (this.isFirst) {
  358. this.isFirst = false
  359. } else {
  360. this.infoFxssbData.fan_wei_ = `本实验室与${val}相关所有活动`
  361. this.infoFxssbData.mu_di_ = `通过对实验室(${val}活动)进行风险评估,识别实验室在(${val}活动)方面存在的潜在风险,评估风险影响程度,制定风险管理策略,减少不利后果发生的概率和影响程度。`
  362. this.infoFxssbData.shi_wu_shuo_ming_ = `年度:${this.infoFxssbData.nian_du_};组长:${this.infoFxssbData.zu_chang_};评估开始日期:${this.infoFxssbData.kai_shi_ri_qi_};风险类型:${val}`
  363. }
  364. }
  365. }
  366. }
  367. },
  368. mounted () {
  369. this.init()
  370. },
  371. beforeDestroy () {
  372. if (this.msg) {
  373. this.msg.close()
  374. }
  375. },
  376. methods: {
  377. // 获取最新数据
  378. async getNewData () {
  379. const sql = `select * from t_fxpgjlb2 where id_='${this.params.id_}'`
  380. const { variables: { data }} = await this.$common.request('sql', sql)
  381. return data
  382. },
  383. // 判断是否已完成
  384. async getIsFinish () {
  385. const data = await this.getNewData()
  386. if (data.length > 0 && data[0].shi_fou_guo_shen_ === '已完成') {
  387. throw new Error('已结束,不可操作!')
  388. }
  389. },
  390. // 快照URL
  391. getReportParams (path, selection, data) {
  392. const { level } = this.$store.getters
  393. const str = `org_=${level.first}&second_=${level.second}&id_=`
  394. const arr = path.split('&')
  395. if (arr.length === 2) {
  396. const fieldArr = arr[1].split('=')
  397. return str + `${data[fieldArr[1]]}`
  398. } else {
  399. // 如果是没有传参,还是原报表路径
  400. return str + `${selection}`
  401. }
  402. },
  403. // 提交
  404. async goSubmit () {
  405. try {
  406. this.$confirm('提交后不可修改,是否确认保存并提交?', '提示', {
  407. confirmButtonText: '继续',
  408. cancelButtonText: '取消',
  409. type: 'warning'
  410. }).then(async () => {
  411. // 提交前自动保存
  412. await this.goSave()
  413. // 判断每个评估人是否已完成识别项
  414. const pinGuRenNum = this.Ids.length
  415. const sql = `select * from t_fxsbpgb2 where parent_id_='${this.params.id_}'`
  416. const { variables: { data }} = await this.$common.request('sql', sql)
  417. const submitNum = new Set(data.map(item => item.bian_zhi_ren_)).size
  418. if (submitNum === pinGuRenNum && data.every(item => item.shi_fou_guo_shen_ === '已完成')) {
  419. // 0.生成快照
  420. const formName = '风险管理/风险识别评估表V2.rpx'
  421. const res = await this.$common.snapshoot({
  422. url: this.$getReportFile(formName, this.getReportParams(formName, this.params.id_, {
  423. ...this.preParams,
  424. shi_fou_guo_shen_: '已完成'
  425. })),
  426. name: this.params.id_,
  427. type: 'pdf'
  428. })
  429. console.log(res)
  430. if (!res.data || !res.data.id) {
  431. console.log('快照生成失败')
  432. } else {
  433. console.log('快照生成成功')
  434. }
  435. // 1.修改状态为已完成 并保存快照
  436. const updateParamsRecord = {
  437. tableName: 't_fxpgjlb2',
  438. updList: [{
  439. where: {
  440. id_: this.params.id_
  441. },
  442. param: {
  443. shi_fou_guo_shen_: '已完成',
  444. kuai_zhao_: res.data.id
  445. }
  446. }]
  447. }
  448. await this.$common.request('update', updateParamsRecord)
  449. // console.log(data)
  450. // 2.推送给措施制定人下一个流程
  451. let count = 0
  452. const addParams = {
  453. tableName: 't_fxkzcsb2',
  454. paramWhere: data.map(item => {
  455. if (item.feng_xian_ying_du !== '风险接受' && item.zhi_ding_ren_) {
  456. count++
  457. return {
  458. di_dian_: this.level,
  459. shi_fou_guo_shen_: '已编制',
  460. bian_zhi_ren_: item.zhi_ding_ren_,
  461. bian_zhi_bu_men_: this.getPersonPosition(item.zhi_ding_ren_.split(',')[0]),
  462. bian_zhi_shi_jian: dayjs().format('YYYY-MM-DD HH:mm:ss'),
  463. gai_jin_bian_hao_: ('FXGJ-' + dayjs().format('YYYYMMDDHHmmss')) + count,
  464. yao_su_tiao_kuan_: item.yao_su_tiao_kuan_,
  465. gong_zuo_huan_jie: item.gong_zuo_huan_jie,
  466. // gong_zuo_miao_shu: item.gong_zuo_miao_shu,
  467. feng_xian_miao_sh: item.feng_xian_miao_sh,
  468. zu_chang_: this.infoFxssbData.zu_chang_,
  469. zu_chang_id_: this.infoFxssbData.zu_chang_id_,
  470. shi_wu_shuo_ming_: this.infoFxssbData.shi_wu_shuo_ming_,
  471. yuan_zhi_shu_: item.feng_xian_zhi_shu,
  472. kong_zhi_fang_fa_: item.xian_xing_kong_zh,
  473. feng_xian_lei_xin: this.infoFxssbData.feng_xian_lei_xin,
  474. qian_fu_jian_: this.infoFxssbData.yi_ju_wen_jian_id,
  475. ji_hua_bian_hao_: this.infoFxssbData.ji_hua_bian_hao_,
  476. ni_cai_qu_kong_zh: item.ni_cai_qu_cuo_shi
  477. }
  478. }
  479. }).filter(i => i !== undefined),
  480. formKey: 'fxcscsbV2',
  481. defKey: 'Process_1li9h0n'
  482. }
  483. console.log(addParams)
  484. if (addParams.paramWhere.length) {
  485. await this.$common.request('add', addParams)
  486. // 3.推送给组长 评估报告流程
  487. const addParams2 = {
  488. tableName: 't_fxkzbg',
  489. paramWhere: [{
  490. di_dian_: this.level,
  491. shi_fou_guo_shen_: '已编制',
  492. bian_zhi_ren_: this.infoFxssbData.zu_chang_id_,
  493. bian_zhi_bu_men_: this.getPersonPosition(this.infoFxssbData.zu_chang_id_),
  494. bian_zhi_shi_jian: dayjs().format('YYYY-MM-DD HH:mm'),
  495. zu_chang_: this.infoFxssbData.zu_chang_,
  496. zu_chang_id_: this.infoFxssbData.zu_chang_id_,
  497. feng_xian_lei_xin: this.infoFxssbData.feng_xian_lei_xin,
  498. kai_shi_ri_qi_: this.infoFxssbData.kai_shi_ri_qi_,
  499. jie_shu_ri_qi_: this.infoFxssbData.jie_shu_ri_qi_,
  500. wan_cheng_ri_qi_: this.infoFxssbData.bao_gao_shi_jian_,
  501. shi_wu_shuo_ming_: this.infoFxssbData.shi_wu_shuo_ming_,
  502. ji_hua_bian_hao_: this.infoFxssbData.ji_hua_bian_hao_,
  503. hui_yi_wen_jian_: this.infoFxssbData.hui_yi_fu_jian_
  504. }],
  505. formKey: 'fxbg',
  506. defKey: 'Process_0mrlsj7'
  507. }
  508. console.log(addParams2)
  509. await this.$common.request('add', addParams2)
  510. console.log('流程推送成功')
  511. } else {
  512. console.log('无需推送')
  513. }
  514. this.$message.success('提交成功')
  515. // 提醒用户推送信息
  516. if (addParams.paramWhere.length) {
  517. this.$alert(`需要改进项${addParams.paramWhere.length}条,已向其中的每位措施制定人推送风险改进流程,同时向组长 ${this.infoFxssbData.zu_chang_} 推送风险报告流程!`, '提交成功', {
  518. confirmButtonText: '确定',
  519. callback: action => {
  520. this.closeDialog(true)
  521. }
  522. })
  523. } else {
  524. this.closeDialog(true)
  525. }
  526. } else {
  527. this.$message.warning('存在未完成风险识别项的评估人员,无法提交!')
  528. return
  529. }
  530. })
  531. .catch(() => {
  532. })
  533. } catch (error) {
  534. this.$message.warning(error.message)
  535. }
  536. },
  537. // id 转 姓名
  538. switchIdtoUserName (id) {
  539. const { userList } = this.$store.getters
  540. const user = userList.find(item => item.userId === id)
  541. return user ? user.userName : ''
  542. },
  543. goPeizhifengxian () {
  544. const buttons = document.querySelector('button[name="peizhifengxian"]')
  545. if (buttons) {
  546. buttons.click()
  547. }
  548. },
  549. handleActionEvent ({ key }) {
  550. switch (key) {
  551. case 'cancel':
  552. this.closeDialog(true)
  553. break
  554. case 'record':
  555. this.goRecord()
  556. break
  557. case 'save':
  558. this.goSave('close')
  559. break
  560. case 'submit':
  561. this.goSubmit()
  562. break
  563. case 'refresh':
  564. this.goRefresh()
  565. break
  566. case 'sendMsg':
  567. this.goSendMsg()
  568. break
  569. case 'peizhifengxian':
  570. this.goPeizhifengxian()
  571. break
  572. default:
  573. break
  574. }
  575. },
  576. // 推送消息给评估人
  577. async goSendMsg () {
  578. const sql2 = `select * from t_fxpgjlb2 where id_='${this.params.id_}'`
  579. const { variables: { data: data2 }} = await this.$common.request('sql', sql2)
  580. if (data2.length > 0 && data2[0].shi_fou_guo_shen_ === '已完成') {
  581. return this.$message('已结束,不可推送消息!')
  582. }
  583. if (!data2[0].ping_gu_ren_yuan_) {
  584. return this.$message.warning('请先指定评估人!')
  585. }
  586. this.$confirm('此操作将通知所有评估人,是否继续?', '提示', {
  587. confirmButtonText: '确定',
  588. cancelButtonText: '取消',
  589. type: 'warning'
  590. }).then(() => {
  591. // console.log(this.Ids)
  592. const allRequests = []
  593. this.Ids.forEach(item => {
  594. allRequests.push(this.$common.sendMsg({
  595. subject: '风险识别项待填写提醒',
  596. content: `您有一份风险识别项待填写,请前往-风险控制-风险评估与措施页面填写,计划编号:${this.infoFxssbData.ji_hua_bian_hao_},组长:${this.infoFxssbData.zu_chang_}。如已提交请忽略。`,
  597. receiverId: item,
  598. canreplay: '0',
  599. skipTypeMsg: JSON.stringify({
  600. skipType: 3,
  601. pathInfo: '/tygl/fxkzV2/fxpgycslb' // 路由
  602. })
  603. }))
  604. })
  605. Promise.all(allRequests).then(() => {
  606. this.$message({
  607. type: 'success',
  608. message: '推送成功!'
  609. })
  610. })
  611. .catch(() => {
  612. this.$message({
  613. type: 'warning',
  614. message: '推送失败!'
  615. })
  616. })
  617. }).catch(() => {
  618. })
  619. },
  620. // 获取人员部门
  621. getPersonPosition (id) {
  622. const userList = this.$store.getters.userList
  623. const bianzhiUserid = userList.find(i => i.userId === id)
  624. if (bianzhiUserid) {
  625. return bianzhiUserid.positionId.split(',')[0]
  626. }
  627. },
  628. checkRequired () {
  629. if (!this.infoFxssbData.nian_du_) {
  630. throw new Error('请填写年度!')
  631. }
  632. if (!this.infoFxssbData.kai_shi_ri_qi_) {
  633. throw new Error('请填写评估开始日期!')
  634. }
  635. if (!this.infoFxssbData.jie_shu_ri_qi_) {
  636. throw new Error('请填写评估结束日期!')
  637. }
  638. if (!this.infoFxssbData.bao_gao_shi_jian_) {
  639. throw new Error('请填写报告完成时间!')
  640. }
  641. // if (!this.infoFxssbData.hui_yi_shi_jian_) {
  642. // throw new Error('请填写首次会议时间!')
  643. // }
  644. // if (!this.infoFxssbData.can_hui_ren_yuan_) {
  645. // throw new Error('请填写参会人员!')
  646. // }
  647. if (!this.infoFxssbData.ping_gu_ren_yuan_) {
  648. throw new Error('请填写评估人员!')
  649. }
  650. if (!this.infoFxssbData.bian_zhi_shi_jian) {
  651. throw new Error('请选择编制时间!')
  652. }
  653. if (!this.infoFxssbData.bian_zhi_bu_men_) {
  654. throw new Error('请选择编制部门!')
  655. }
  656. },
  657. async goAdd () {
  658. try {
  659. const addParamsRecord = {
  660. tableName: 't_fxpgjlb2',
  661. paramWhere: [this.infoFxssbData]
  662. }
  663. const { variables: { cont }} = await this.$common.request('add', addParamsRecord)
  664. if (cont.length) {
  665. this.$message.success('添加成功')
  666. this.closeDialog(true)
  667. }
  668. } catch (error) {
  669. console.log(error)
  670. this.$message.warning('添加失败')
  671. }
  672. },
  673. async goEdit (flag) {
  674. try {
  675. // 先检查状态
  676. await this.getIsFinish()
  677. // 更新主表
  678. const updateParamsRecord = {
  679. tableName: 't_fxpgjlb2',
  680. updList: [{
  681. where: {
  682. id_: this.params.id_
  683. },
  684. param: this.infoFxssbData
  685. }]
  686. }
  687. await this.$common.request('update', updateParamsRecord)
  688. // 当前人员数组
  689. const curIds = this.infoFxssbData.ping_gu_ren_yuan_.split(',')
  690. // 计算需要增加项
  691. const addedIds = curIds.filter(item => !this.Ids.includes(item))
  692. // 计算需要更新项
  693. const updatedIds = curIds.filter(item => this.Ids.includes(item))
  694. // 计算需要删除项
  695. const deletedIds = this.Ids.filter(id => !curIds.includes(id))
  696. console.log(addedIds, updatedIds, deletedIds)
  697. // 删除
  698. if (deletedIds.length > 0) {
  699. const sql3 = `select *from t_fxsbpgb2 where parent_id_='${this.params.id_}' and bian_zhi_ren_ in (${deletedIds.map(id => `'${id}'`).join(', ')})`
  700. const { variables: { data: data3 }} = await this.$common.request('sql', sql3)
  701. // console.log(data3)
  702. if (data3.length > 0) {
  703. const params = {
  704. tableName: 't_fxsbpgb2',
  705. paramWhere: {
  706. id_: data3.map(item => item.id_).join(',')
  707. }
  708. }
  709. console.log(params)
  710. await this.$common.request('delete', params)
  711. console.log('删除成功')
  712. }
  713. }
  714. if (flag === 'close') {
  715. this.closeDialog(true)
  716. this.$message.success('修改成功')
  717. } else {
  718. await this.goRefresh() // 修改之后刷新
  719. }
  720. } catch (error) {
  721. this.$message.warning(error.message)
  722. throw new Error(error.message)
  723. }
  724. },
  725. async goSave (flag) {
  726. try {
  727. this.checkRequired()
  728. if (this.isEdit) {
  729. await this.goEdit(flag)
  730. } else {
  731. await this.goAdd()
  732. }
  733. } catch (error) {
  734. this.$message.warning(error.message)
  735. throw new Error(error.message)
  736. }
  737. },
  738. // 刷新
  739. async goRefresh () {
  740. this.loading = true
  741. if (this.msg) {
  742. this.msg.close()
  743. }
  744. await this.init()
  745. if (this.$refs.RiskPeopleTableRef) {
  746. await this.$refs.RiskPeopleTableRef.getPeopleList()
  747. }
  748. this.loading = false
  749. },
  750. // 关闭当前窗口
  751. closeDialog (needRefresh) {
  752. this.dialogVisible = false
  753. if (needRefresh) {
  754. this.$emit('close')
  755. }
  756. if (this.msg) {
  757. this.msg.close()
  758. }
  759. },
  760. // 弹出提醒
  761. async showAlert () {
  762. if (!this.isPingGuRen || this.isFinished) return
  763. // 判断是否已经填写风险识别项
  764. const sql = `select * from t_fxsbpgb2 where parent_id_='${this.params.id_}' and bian_zhi_ren_='${this.userId}'`
  765. const { variables: { data }} = await this.$common.request('sql', sql)
  766. let status = '填写'
  767. let type = 'warning'
  768. if (data.length > 0) {
  769. if (data.every(item => item.shi_fou_guo_shen_ === '已完成')) {
  770. return
  771. } else {
  772. status = '提交'
  773. type = 'success'
  774. }
  775. }
  776. this.msg = this.$notify({
  777. offset: 50,
  778. type: type,
  779. title: `您有一份风险识别评估表待${status}!`,
  780. message: `点击前去${status}`,
  781. showClose: false,
  782. duration: 0,
  783. onClick: () => {
  784. this.$refs.RiskDetailRef.open(this.params)
  785. }
  786. })
  787. },
  788. async init () {
  789. this.isEdit = !!(this.params && this.params.id_)
  790. if (this.isEdit) {
  791. this.infoFxssbData = this.params
  792. this.preParams = JSON.parse(JSON.stringify(this.params))
  793. this.isPingGuRen = this.params.ping_gu_ren_yuan_.indexOf(this.userId) >= 0
  794. this.isZuZhang = this.userId === this.infoFxssbData.zu_chang_id_
  795. this.isFinished = this.params && this.params.shi_fou_guo_shen_ === '已完成'
  796. this.readonly = !!((!this.isZuZhang || this.isFinished))
  797. if (this.params.ping_gu_ren_yuan_) {
  798. this.Ids = this.params.ping_gu_ren_yuan_.split(',')
  799. } else {
  800. this.Ids = []
  801. }
  802. await this.showAlert()
  803. } else {
  804. this.readonly = false
  805. this.infoFxssbData.di_dian_ = this.level
  806. this.infoFxssbData.ji_hua_bian_hao_ = 'FX-' + dayjs().format('YYYYMMDDHHmmss')
  807. this.infoFxssbData.nian_du_ = dayjs().format('YYYY')
  808. this.infoFxssbData.bian_zhi_bu_men_ = this.position
  809. this.infoFxssbData.bian_zhi_ren_ = this.userId
  810. this.infoFxssbData.bian_zhi_shi_jian = dayjs().format('YYYY-MM-DD HH:mm:ss')
  811. this.infoFxssbData.zu_chang_id_ = this.userId
  812. this.infoFxssbData.kai_shi_ri_qi_ = dayjs().format('YYYY-MM-DD')
  813. this.infoFxssbData.jie_shu_ri_qi_ = dayjs().format('YYYY-MM-DD')
  814. this.infoFxssbData.feng_xian_lei_xin = '质量'
  815. this.infoFxssbData.shi_ji_ = '定期评估'
  816. this.infoFxssbData.fan_wei_ = '本实验室与质量相关所有活动'
  817. this.infoFxssbData.fang_fa_ = '定量风险评估法'
  818. this.infoFxssbData.mu_di_ = '通过对实验室(质量活动)进行风险评估,识别实验室在(质量活动)方面存在的潜在风险,评估风险影响程度,制定风险管理策略,减少不利后果发生的概率和影响程度。'
  819. this.infoFxssbData.hui_yi_shi_jian_ = dayjs().format('YYYY-MM-DD HH:mm')
  820. this.$nextTick(() => {
  821. this.infoFxssbData.shi_wu_shuo_ming_ = `年度:${this.infoFxssbData.nian_du_};组长:${this.infoFxssbData.zu_chang_};评估开始日期:${this.infoFxssbData.kai_shi_ri_qi_};风险类型:${this.infoFxssbData.feng_xian_lei_xin}`
  822. })
  823. }
  824. }
  825. }
  826. }
  827. </script>
  828. <style lang="scss" scoped>
  829. .paper-detail-dialog {
  830. ::v-deep {
  831. .el-dialog__header {
  832. text-align: center;
  833. }
  834. }
  835. .container {
  836. display: flex;
  837. width: 100%;
  838. justify-content: center;
  839. .left{
  840. height: calc(100vh - 100px);
  841. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  842. padding:10px;
  843. overflow-y: auto;
  844. }
  845. .right{
  846. height: calc(100vh - 100px);
  847. flex: 1;
  848. padding:10px;
  849. .text{
  850. line-height: 1.5;
  851. }
  852. overflow-y: auto;
  853. }
  854. }
  855. }
  856. .required-star {
  857. color: red;
  858. margin-right: 4px;
  859. }
  860. .dialog-title{
  861. display: flex;
  862. align-items: center;
  863. justify-content: center;
  864. div{
  865. position: absolute;
  866. right:8vw;
  867. }
  868. .dialogtitle{
  869. font-size: 22px;
  870. font-family: SimHei;
  871. font-weight: bold;
  872. color: #222;
  873. }
  874. }
  875. </style>