table-score.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <HcTable ui="no-border" is-new :column="tableColumn" :datas="tableData" :loading="tableLoading" :is-index="false">
  3. <template #integrality="{ row }">
  4. <div v-if="row.isEdit" class="table-score-input-box">
  5. <el-input-number v-model="row.integrality" placeholder="" :controls="false" style="width: 100%;" :precision="0" />
  6. </div>
  7. <span v-else>{{ row.integrality || '-' }}</span>
  8. </template>
  9. <template #integralityDeduction="{ row }">
  10. <div v-if="row.isEdit" class="table-score-input-box">
  11. <el-input-number v-model="row.integralityDeduction" placeholder="" :controls="false" style="width: 100%;" :precision="0" />
  12. </div>
  13. <span v-else>{{ row.integralityDeduction || '-' }}</span>
  14. </template>
  15. <template #normativeDeduction="{ row }">
  16. <div v-if="row.isEdit" class="table-score-input-box">
  17. <el-input-number v-model="row.normativeDeduction" placeholder="" :controls="false" style="width: 100%;" :precision="0" />
  18. </div>
  19. <span v-else>{{ row.normativeDeduction || '-' }}</span>
  20. </template>
  21. <template #normative="{ row }">
  22. <div v-if="row.isEdit" class="table-score-input-box">
  23. <el-input-number v-model="row.normative" placeholder="" :controls="false" style="width: 100%;" :precision="0" />
  24. </div>
  25. <span v-else>{{ row.normative || '-' }}</span>
  26. </template>
  27. <template #action="{ row }">
  28. <el-button v-if="row.isEdit" type="success" size="small" @click="saveClick(row)">
  29. 保存
  30. </el-button>
  31. <el-button v-else type="primary" size="small" @click="editClick(row)">
  32. 编辑
  33. </el-button>
  34. </template>
  35. </HcTable>
  36. </template>
  37. <script setup>
  38. import { onActivated, ref, watch } from 'vue'
  39. import { getArrValue } from 'js-fast-way'
  40. import writeApi from '~api/transfer/write-conclusion'
  41. //参数
  42. const props = defineProps({
  43. projectId: {
  44. type: [String, Number],
  45. default: '',
  46. },
  47. contractId: {
  48. type: [String, Number],
  49. default: '',
  50. },
  51. type: {
  52. type: [String, Number],
  53. default: '',
  54. },
  55. })
  56. //变量
  57. const projectId = ref(props.projectId)
  58. const contractId = ref(props.contractId)
  59. const typeId = ref(props.type)
  60. //监听
  61. watch(() => [
  62. props.type,
  63. ], ([type]) => {
  64. typeId.value = type
  65. getTotalData()
  66. })
  67. //渲染完成
  68. onActivated(() => {
  69. getTotalData()
  70. })
  71. //表格数据
  72. const tableColumn = ref([
  73. { key:'scoreItem', name: '项目' },
  74. { key:'integrality', name: '完整性', width: 80, align: 'center' },
  75. { key:'integralityDeduction', name: '扣分', width: 80, align: 'center' },
  76. { key:'normative', name: '规范性', width: 80, align: 'center' },
  77. { key:'normativeDeduction', name: '扣分', width: 80, align: 'center' },
  78. { key:'action', name: '操作', width: 80, align: 'center' },
  79. ])
  80. const tableData = ref([
  81. ])
  82. const tableLoading = ref(false)
  83. const getTotalData = async ()=>{
  84. tableLoading.value = true
  85. const { error, code, data } = await writeApi.getItemByUnit({
  86. projectId: projectId.value,
  87. unitType:typeId.value,
  88. })
  89. tableLoading.value = false
  90. if (!error && code === 200) {
  91. tableData.value = getArrValue(data)
  92. } else {
  93. tableData.value = []
  94. }
  95. }
  96. //编辑
  97. const editClick = (row) => {
  98. row.isEdit = true
  99. }
  100. //保存
  101. const saveClick = async (row) => {
  102. const { error, code, msg } = await writeApi.updateExpertScore({
  103. ...row,
  104. })
  105. if (!error && code === 200) {
  106. window.$message.success(msg)
  107. row.isEdit = false
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. .table-score-input-box {
  113. position: relative;
  114. text-align: left;
  115. }
  116. </style>