Newer
Older
KaiFengPC / src / views / spongePerformance / waterUtilizationRate / surfaceWater / detial / tableDalgo.vue
@zhangdeliang zhangdeliang on 23 May 5 KB 初始化项目
  1. <template>
  2. <div class="water-analysis-page">
  3. <div class="top">
  4. <el-form label-width="auto" :rules="projectEstimateRules" inline ref="ruleForm" :model="FormList" :disabled="typeList.type == 1">
  5. <div v-for="i in typeList.monitorDynamicTableTitleList" style="display: flex; flex-direction: column">
  6. <el-form-item
  7. v-if="i.key == 'real' || i.key == 'target'"
  8. v-for="k in i.titleGroup"
  9. :label="i.key == 'real' ? '实际' + k.value + ':' : '目标' + k.value + ':'"
  10. :prop="k.key"
  11. :disabled="typeList.type == 1 || typeList.type == 2"
  12. >
  13. <el-input
  14. :disabled="i.key != 'real'"
  15. v-model="FormList[k.key]"
  16. :placeholder="k.placeholder"
  17. @change="ChangeClick(k.key, FormList[k.key])"
  18. >
  19. </el-input>
  20. </el-form-item>
  21. <el-form-item v-else :label="i.value + ':'" :prop="i.key" :disabled="typeList.type == 1 || typeList.type == 2">
  22. <el-upload
  23. v-if="i.key == 'attachFileList'"
  24. v-model:file-list="fileList1"
  25. class="upload-demo"
  26. action="/system/upload"
  27. :headers="uploadHeader"
  28. multiple
  29. :on-preview="handlePreview"
  30. :before-remove="beforeRemove"
  31. style="width: 100vh"
  32. >
  33. <el-button type="primary">选择文件</el-button>
  34. </el-upload>
  35. <div
  36. v-else-if="i.key == 'standardFlag' && typeList.iSstandardFlag"
  37. :style="{ color: typeList.iSstandardFlag ? '#108ee9' : 'red' }"
  38. >
  39. {{ typeList.iSstandardFlag ? '达标' : '未达标' }}
  40. </div>
  41. <div
  42. v-else-if="i.key == 'standardFlag' && !typeList.iSstandardFlag"
  43. :style="{ color: IsStandFlag1 > 0 && IsStandFlag2 > 0 ? '#108ee9' : 'red' }"
  44. >
  45. <span v-show="false">{{ IsStandFlag1 > 0 && IsStandFlag2 > 0 ? (IsStandText = 1) : (IsStandText = 0) }}</span>
  46. {{ IsStandFlag1 > 0 && IsStandFlag2 > 0 ? '达标' : '未达标' }}
  47. </div>
  48. <div v-else>
  49. {{ FormList[i.key] }}
  50. </div>
  51. </el-form-item>
  52. </div>
  53. </el-form>
  54. </div>
  55. </div>
  56. </template>
  57. <script setup>
  58. import { projectInfoEdit } from '@/api/spongePerformance/prevention';
  59. import { getToken } from '@/utils/auth';
  60. import { projectEstimateRules } from '@/utils/rules';
  61. import { ElMessage, ElMessageBox } from 'element-plus';
  62. const { proxy } = getCurrentInstance();
  63. const uploadHeader = ref({
  64. Authorization: 'Bearer ' + getToken(),
  65. });
  66. const { typeList } = defineProps(['typeList']);
  67. const emits = defineEmits();
  68. defineExpose({ submit, closed, resetFiled });
  69. const IsStandFlag1 = ref(0);
  70. const IsStandFlag2 = ref(0);
  71. const IsStandText = ref('');
  72. let FormList = ref({ projectNo: '', fileSaveRequestList: [] });
  73. function ChangeClick(v, m) {
  74. console.log('v', v);
  75. console.log('m', m);
  76. typeList.iSstandardFlag = null;
  77. if (v == 'realCXQ') {
  78. console.log('object1', m * 1 - FormList.value.targetCXQ * 1);
  79. IsStandFlag1.value = m * 1 - FormList.value.targetCXQ * 1;
  80. } else {
  81. console.log('object2', m * 1 - FormList.value.targetDBMJZJCQMJ * 1);
  82. IsStandFlag2.value = m * 1 - FormList.value.targetCXQ * 1;
  83. }
  84. }
  85. const fileList1 = ref([]);
  86. function handlePreview(file) {
  87. return ElMessageBox.confirm(`下载此文件: ${file.name}?`).then(
  88. () => window.open(file.url),
  89. () => false
  90. );
  91. }
  92. function beforeRemove(file) {
  93. return true;
  94. }
  95. function submit() {
  96. proxy.$refs.ruleForm.validate(valid => {
  97. if (valid) {
  98. const fileSaveRequestList = [];
  99. fileList1.value.forEach(element => {
  100. if (element.hasOwnProperty('response')) {
  101. element.response.data.refType = 'proProjectBudget';
  102. fileSaveRequestList.push(element.response.data);
  103. } else {
  104. fileSaveRequestList.push(element);
  105. }
  106. });
  107. const itemUpdateFieldRequestList = [
  108. { id: typeList.data['CXQ-id'], realValue: FormList.value.realCXQ, standardFlag: IsStandFlag1.value > 0 ? 1 : 0 },
  109. {
  110. id: typeList.data['DBMJZJCQMJ-id' || 0],
  111. realValue: FormList.value.realDBMJZJCQMJ,
  112. standardFlag: IsStandFlag2.value > 0 ? 1 : 0,
  113. },
  114. ];
  115. FormList.value = {
  116. itemDataType: typeList.itemDataType,
  117. standardFlag: typeList.iSstandardFlag || IsStandText.value,
  118. itemUpdateFieldRequestList,
  119. fileSaveRequestList,
  120. performanceEvaluateId: typeList.data.performanceEvaluateId,
  121. };
  122. console.log('FormList.value', FormList.value);
  123. projectInfoEdit(FormList.value).then(({ code }) => {
  124. if (code == 200) {
  125. emits('onModalClose');
  126. }
  127. });
  128. }
  129. // }
  130. });
  131. }
  132. function loadProjerctListData() {
  133. console.log('typeListtypeList', typeList);
  134. FormList.value = typeList.data;
  135. fileList1.value = typeList.fileList1;
  136. proxy.$refs.ruleForm.resetFields();
  137. }
  138. function resetFiled() {
  139. proxy.$refs.ruleForm.resetFields();
  140. fileList1.value = [];
  141. }
  142.  
  143. function closed() {
  144. emits('onModalClose');
  145. }
  146. onMounted(() => {
  147. loadProjerctListData();
  148. });
  149. </script>
  150. <style lang="scss" scoped>
  151. .water-analysis-page {
  152. padding: 20px;
  153. }
  154. </style>