index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <div class="pblm-detail-wrapper">
  3. <van-form @submit="onSubmit">
  4. <card01 v-if="pblm && pblm.length > 0"
  5. :description="`工程地址:${pblm.location}<br/>问题类型:${listTypeConvert(pblm.listType)}`"
  6. :title="pblm.name + ''" icon="label"
  7. style="margin-top: 0;"/>
  8. <div class="pblm-detail-label">
  9. <span>违规事项</span>
  10. <van-button size="mini" type="primary" @click="showTacObjPblmstbPopup()">选择违规事项</van-button>
  11. </div>
  12. <van-cell-group inset>
  13. <van-field v-model="tacObjPblmstb.pblmTypeDesc" autosize label="问题类型" label-align="top"
  14. placeholder="问题类型" readonly rows="1" type="textarea"/>
  15. <van-field v-model="tacObjPblmstb.pblmsDesc" autosize label="违规事项" label-align="top" placeholder="违规事项"
  16. readonly rows="2" type="textarea"/>
  17. <van-field v-model="tacObjPblmstb.relativeLaw" autosize label="法规条款" label-align="top"
  18. placeholder="法规条款" readonly rows="2" type="textarea"/>
  19. <van-field v-model="tacObjPblmstb.lawContent" autosize label="法规内容" label-align="top" placeholder="法规内容"
  20. readonly rows="2" type="textarea"/>
  21. <van-field v-model="pblm.note" autosize label="备注" label-align="top" placeholder="备注" rows="2"
  22. type="textarea"/>
  23. </van-cell-group>
  24. <div class="pblm-detail-label">问题描述</div>
  25. <van-cell-group inset>
  26. <van-field v-model="pblm.pblmNm" autosize label="发现问题" label-align="top" placeholder="发现问题" rows="2"
  27. type="textarea"/>
  28. <van-field v-model="pblm.pblmDesc" autosize label="问题阐述" label-align="top" placeholder="问题阐述" rows="2"
  29. type="textarea"/>
  30. <van-field v-model="pblm.pblmReason" autosize label="主要原因分析" label-align="top" placeholder="主要原因分析"
  31. rows="2" type="textarea"/>
  32. <van-field v-model="pblm.pblmSggtn" autosize label="整改意见及建议" label-align="top"
  33. placeholder="整改意见及建议"
  34. rows="2" type="textarea"/>
  35. <van-field v-model="pblm.spclRvwOptn" autosize label="稽察组长复核意见" label-align="top"
  36. placeholder="稽察组长复核意见"
  37. rows="2" type="textarea"/>
  38. <GwSelect02 v-model:value="pblm.pblmPasi" :columns="cateObjList" label="问题严重性"></GwSelect02>
  39. <van-field label="是否典型问题" name="radio">
  40. <template #input>
  41. <van-radio-group v-model="pblm.ifCasePblm" direction="horizontal">
  42. <van-radio name="1">是</van-radio>
  43. <van-radio name="0">否</van-radio>
  44. </van-radio-group>
  45. </template>
  46. </van-field>
  47. <van-field label="排序序号" name="stepper">
  48. <template #input>
  49. <van-stepper v-model="pblm.sn"/>
  50. </template>
  51. </van-field>
  52. <van-field label="文件上传" label-align="top" name="uploader">
  53. <template #input>
  54. <van-uploader v-model="gwComFileList"/>
  55. </template>
  56. </van-field>
  57. </van-cell-group>
  58. <div class="pblm-detail-label">责任主体</div>
  59. <van-cell-group inset>
  60. <div v-for="(item, index) in subjectList" :key="item.id" class="pblmSubjectList">
  61. <van-row style="border-bottom: 1px dashed #CDD0D6;">
  62. <van-col span="20">
  63. <GwSelect02 v-model:value="item.subId" :columns="objSubjectTypeColumns" label="单位性质"></GwSelect02>
  64. <GwSelect02 v-model:value="item.unitNm" :columns="getObjSubjectColumns(index)"
  65. label="单位名称">
  66. </GwSelect02>
  67. </van-col>
  68. <van-col span="4" style="display: flex;justify-content: center;align-items: center;"
  69. @click="removePblmSubject(index)">
  70. <van-icon color="#000" name="delete-o" size="1rem"/>
  71. </van-col>
  72. </van-row>
  73. </div>
  74. <van-button block hairline plain round @click="addPblmSubject">
  75. <van-icon color="#000" name="plus" size="1rem" style="margin-right: 5px;"/>
  76. 添加单位
  77. </van-button>
  78. </van-cell-group>
  79. <div style="margin: 16px;">
  80. <van-button block native-type="submit" round type="primary">
  81. 提交
  82. </van-button>
  83. </div>
  84. </van-form>
  85. <van-popup v-model:show="tacObjPblmstbShow" :style="{ width: '80%', height: '100%' }" position="left">
  86. <tacObjPblmstbList :listType="pblm.listType" style="z-index:3000;"
  87. @change="changeTacObjPblmstb"></tacObjPblmstbList>
  88. </van-popup>
  89. </div>
  90. </template>
  91. <script setup>
  92. import {computed, onMounted, ref, watch} from "vue";
  93. import {useRoute} from "vue-router";
  94. import {showNotify} from 'vant';
  95. import card01 from '@/components/card01.vue';
  96. import GwSelect02 from '@/components/GwSelect02.vue';
  97. import tacObjPblmstbList from './TacObjPblmstbList.vue';
  98. import {listTypeConvert} from "@/utils/convert";
  99. import {getTacQuestionById} from "@/api/inspect";
  100. import {addTacQuestion, getIllegalActById, getTacUnitList} from "@/api/questions";
  101. import {copyObj} from "@/utils/ruoyi";
  102. import {useUserStore} from "@/stores/user";
  103. const route = useRoute();
  104. const userStore = useUserStore();
  105. const listType = ref(route.query.inspectType || '1');
  106. const pblm = ref({});
  107. const tacObjPblmstb = computed(() => pblm.value.tacObjPblmstb || {});
  108. const cateObjList = ref([]);
  109. const objSubjectList = ref([]);
  110. // const objSubjectTypeColumns = computed(() => objSubjectList.value?.map(i => {
  111. // return {text: i.subName, value: i.id}
  112. // }) || []);
  113. const objSubjectTypeColumns = computed(function() {
  114. let list = objSubjectList.value ? objSubjectList.value : [];
  115. let mappedList = list.map(function(i) {
  116. return {
  117. text: i.subName,
  118. value: i.id
  119. };
  120. });
  121. return mappedList || [];
  122. });
  123. const objSubjects = ref({});
  124. // const gwComFileList = computed(() => pblm.value.gwComFileList?.map(i => {
  125. // return {url: process.env.VUE_APP_BASE_HOST + process.env.VUE_APP_BASE_API + i.filePath}
  126. // }) || []);
  127. const gwComFileList = computed(function() {
  128. const fileList = pblm.value && pblm.value.gwComFileList ? pblm.value.gwComFileList : [];
  129. const mappedList = fileList.map(function(item) {
  130. return {
  131. url: process.env.VUE_APP_BASE_HOST + process.env.VUE_APP_BASE_API + item.filePath
  132. };
  133. });
  134. return mappedList || [];
  135. });
  136. /**
  137. * 责任主体
  138. */
  139. const subjectList = ref([]);
  140. const tacObjPblmstbShow = ref(false);
  141. function getQuestionData() {
  142. getTacQuestionById(route.params.id).then(res => {
  143. if (res.data && Object.keys(res.data).length > 0) {
  144. pblm.value = res.data
  145. listType.value = res.data.listType
  146. subjectList.value = res.data.pblmSubjectList;
  147. cateObjList.value = res.data.tacObjPblmstb.cateObjList.map(i => {
  148. return {text: i.desc, value: i.cate}
  149. }) || []
  150. objSubjectList.value = pblm.value.tacObjPblmstb.objSubjectList
  151. }
  152. })
  153. }
  154. /**
  155. * 选择违规事项
  156. */
  157. function showTacObjPblmstbPopup() {
  158. tacObjPblmstbShow.value = true;
  159. }
  160. function changeTacObjPblmstb(data) {
  161. if (!data || !data.id) {
  162. return
  163. }
  164. getIllegalActById(data.id).then(res => {
  165. tacObjPblmstbShow.value = false;
  166. pblm.value.tacObjPblmstb = res.data;
  167. pblm.value.pblmstdId = res.data.id;
  168. cateObjList.value = res.data.cateObjList.map(i => {
  169. return {text: i.desc, value: i.cate}
  170. }) || []
  171. objSubjectList.value = res.data.objSubjectList
  172. })
  173. }
  174. // eslint-disable-next-line no-unused-vars
  175. function uniArr(tempArr) {
  176. var newTempArr = [];
  177. if (tempArr && tempArr.length > 0) {
  178. tempArr.forEach((item) => {
  179. if (item.unitNm || item.subId) {
  180. newTempArr.push(item);
  181. }
  182. })
  183. for (let i = 0; i < newTempArr.length; i++) {
  184. for (let j = i + 1; j < newTempArr.length; j++) {
  185. if ((newTempArr[i].unitNm == newTempArr[j].unitNm) && (newTempArr[i].subId == newTempArr[j].subId)) {
  186. newTempArr.splice(j, 1);
  187. j--;
  188. }
  189. }
  190. }
  191. return newTempArr;
  192. } else {
  193. return [];
  194. }
  195. }
  196. /**
  197. * 保存问题
  198. */
  199. function onSubmit() {
  200. const data = copyObj(pblm.value)
  201. if (!data.pblmstdId) {
  202. showNotify({type: 'warning', message: '请选择问题'});
  203. return
  204. }
  205. if (!data.sn) {
  206. data.sn = 0
  207. }
  208. if (data.pblmReason && data.pblmReason.length >= 500) {
  209. showNotify({type: 'warning', message: '主要原因分析需字数小于500字!'});
  210. return;
  211. }
  212. if (data.pblmSggtn && data.pblmSggtn.length >= 1000) {
  213. showNotify({type: 'warning', message: '整改意见及建议字数需小于1000字!'});
  214. return;
  215. }
  216. if (data.spclRvwOptn && data.spclRvwOptn.length >= 500) {
  217. showNotify({type: 'warning', message: '稽察组长意见字数需小于500字!'});
  218. return;
  219. }
  220. if (data.pblmRevision && data.pblmRevision.length >= 500) {
  221. showNotify({type: 'warning', message: '问题修改理由字数需小于500字!'});
  222. return;
  223. }
  224. data.relativeLaw = data.tacObjPblmstb.relativeLaw
  225. data.lawContent = data.tacObjPblmstb.lawContent
  226. data.pblmSubjectList = subjectList.value
  227. if (!data.id) {
  228. // data.stepId = stepId
  229. data.objId = route.query.objId;
  230. data.rgstrId = route.query.rgstrId;
  231. data.listType = listType.value;
  232. data.persId = userStore.userId;
  233. }
  234. let unitNames = []
  235. let subIds = []
  236. const unitArray = uniArr(subjectList.value);
  237. unitArray.forEach((ele) => {
  238. unitNames.push(ele.unitNm)
  239. subIds.push(ele.subId)
  240. })
  241. unitNames = unitNames.filter(function (s) {
  242. return s && s.trim();
  243. });
  244. subIds = subIds.filter(function (s) {
  245. return s && s.trim();
  246. });
  247. if ((unitNames.length != subIds.length) && unitNames.length != 0 && subIds.length != 0) {
  248. showNotify({type: 'warning', message: '对应的单位性质或单位名称其中一个不能为空'});
  249. return false;
  250. }
  251. data.subjectNames = unitNames.join(',')
  252. data.subjectIds = subIds.join(',')
  253. addTacQuestion(data).then(res => {
  254. pblm.value.id = res.data.id
  255. showNotify({type: 'success', message: '保存成功'});
  256. })
  257. }
  258. async function getObjSubjects(rgstrId, subId) {
  259. if (rgstrId && subId) {
  260. return await getTacUnitList(rgstrId, subId).then(res => res.data) || []
  261. } else {
  262. return []
  263. }
  264. }
  265. function getObjSubjectColumns(index) {
  266. return (objSubjects.value[index] || []).map(i => {
  267. return {text: i.sysNm, value: i.sysNm}
  268. })
  269. }
  270. /**
  271. * 添加责任主体
  272. */
  273. function addPblmSubject() {
  274. subjectList.value.push({});
  275. }
  276. function removePblmSubject(index) {
  277. subjectList.value.splice(index, 1);
  278. }
  279. onMounted(() => {
  280. getQuestionData();
  281. })
  282. watch(() => subjectList, (list) => {
  283. if (list.value && list.value.length > 0) {
  284. list.value.forEach((item, index) => {
  285. if (item.subId) {
  286. getObjSubjects(pblm.value.rgstrId, item.subId).then(res => {
  287. objSubjects.value[index] = res;
  288. })
  289. }
  290. })
  291. }
  292. }, {deep: true, immediate: true})
  293. </script>
  294. <style lang="scss" scoped>
  295. .pblm-detail-wrapper {
  296. height: 100%;
  297. padding: 10px 0;
  298. overflow: auto;
  299. .pblm-detail-label {
  300. padding: 10px 16px;
  301. color: #606266;
  302. display: flex;
  303. align-items: center;
  304. justify-content: space-between;
  305. }
  306. }
  307. </style>
  308. <style lang="scss">
  309. .van-cell-group--inset {
  310. margin: 0 10px;
  311. }
  312. </style>