checkPop.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="midPopUp" v-if="checkPop">
  3. <div class="container" @click.stop>
  4. <div class="title titleText" style="font-size: 38px">设备点检项目</div>
  5. <div class="title describeText">(需填完后开工)</div>
  6. <el-scrollbar class="listBody">
  7. <el-form ref="formRef" :model="checkListArray" label-width="aotu">
  8. <div
  9. class="item"
  10. v-for="(item, index) in checkListArray.array"
  11. :key="item.key"
  12. >
  13. <el-form-item
  14. :label="`${index + 1}.` + item.deviceName + '-' + item.deviceNo"
  15. :rules="{
  16. required: true,
  17. message: '该选项为必选',
  18. trigger: 'change',
  19. }"
  20. :prop="'array.' + index + '.result'"
  21. >
  22. <div class="showInfo">
  23. <span class="remark">&nbsp;( {{ item.showremark }} ) :</span>
  24. <el-radio-group v-model="item.result">
  25. <el-radio :value="0">正常</el-radio>
  26. <el-radio :value="1">异常</el-radio>
  27. </el-radio-group>
  28. </div>
  29. </el-form-item>
  30. <el-input
  31. v-if="item.result == 1"
  32. v-model="item.remark"
  33. type="textarea"
  34. placeholder="请输入异常原因"
  35. />
  36. </div>
  37. </el-form>
  38. </el-scrollbar>
  39. <div class="btns">
  40. <el-button
  41. type="primary"
  42. @click="validate"
  43. class="titleText"
  44. style="width: 260px; height: 50px; border-radius: 16px"
  45. >提 交
  46. </el-button>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script lang="ts" setup>
  52. import { checkList, maintenanceCheck } from "@/api/process";
  53. //点检项数组
  54. const checkListArray = reactive({ array: [] });
  55. const formRef = ref(null);
  56. const checkPop = ref(false);
  57. const getCheckList = async () => {
  58. const { data } = await checkList();
  59. checkListArray.array = data;
  60. checkListArray.array.forEach((item, index) => {
  61. let str = "";
  62. item.result = null;
  63. item.key = index;
  64. str = JSON.parse(JSON.stringify(item.remark));
  65. item.showremark = str;
  66. item.remark = "";
  67. });
  68. if (checkListArray.array.length > 0) {
  69. checkPop.value = true;
  70. } else {
  71. checkPop.value = false;
  72. }
  73. };
  74. const validate = () => {
  75. formRef.value.validate((valid) => {
  76. if (valid) {
  77. submit();
  78. } else {
  79. ElMessage.error("请检查是否有未填项");
  80. }
  81. });
  82. };
  83. const submit = async () => {
  84. const { data, code } = await maintenanceCheck(checkListArray.array);
  85. if (code == "200") {
  86. ElMessage.success("提交成功!祝开工顺利");
  87. checkPop.value = false;
  88. }
  89. };
  90. watch(
  91. () => checkListArray,
  92. () => {
  93. if (checkListArray.array.length > 0) {
  94. checkPop.value = true;
  95. } else {
  96. checkPop.value = false;
  97. }
  98. }
  99. );
  100. onMounted(() => {
  101. getCheckList();
  102. });
  103. </script>
  104. <style lang="scss" scoped>
  105. .title {
  106. width: 100%;
  107. height: 50px;
  108. text-align: center;
  109. }
  110. :deep(label) {
  111. display: inline-block;
  112. }
  113. .listBody {
  114. height: calc(100% - 160px);
  115. padding: 0 $p20;
  116. .item {
  117. width: 100%;
  118. background-color: white;
  119. border-radius: 16px;
  120. margin: 10px 0;
  121. padding: $p10 $p20;
  122. .showInfo {
  123. .remark {
  124. font-size: $f20;
  125. color: red;
  126. margin-right: 5px;
  127. }
  128. }
  129. }
  130. }
  131. .btns {
  132. width: 100%;
  133. height: 50px;
  134. @include flex;
  135. }
  136. //表单字体样式
  137. :deep(.el-form-item__label) {
  138. font-size: $f20;
  139. max-width: 600px;
  140. display: inline-block;
  141. height: auto;
  142. padding-right: 0px;
  143. }
  144. :deep(.el-radio__label) {
  145. font-size: $f20;
  146. }
  147. :deep(.el-radio) {
  148. display: flex;
  149. align-items: center;
  150. }
  151. :deep(.el-textarea__inner) {
  152. font-size: $f20;
  153. }
  154. </style>