aqTable.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <div>
  3. <div class="act_header">
  4. <div>{{ title }}</div>
  5. <div v-if="!readonly" class="row">
  6. <u-button text="添加" @tap="add"></u-button>
  7. </div>
  8. </div>
  9. <table class="static-table">
  10. <tr>
  11. <td>序号</td>
  12. <td>检验项目</td>
  13. <td>检验结果</td>
  14. <td>单项结论</td>
  15. <td>检验方法</td>
  16. <td v-if="! readonly">操作</td>
  17. </tr>
  18. <tr v-for="(item, index) in acTableData" :key="item.key">
  19. <td>{{index + 1}}</td>
  20. <td>
  21. <simple-select v-model="item.inspectionItemId" :data="enumId" load-type="dict" :readonly="readonly"></simple-select>
  22. </td>
  23. <td>
  24. <u--input v-model="item.inspectionValue" :readonly="readonly"></u--input>
  25. </td>
  26. <td>
  27. <simple-select v-model="item.singleConclusion" data="OPT4" load-type="static" :readonly="readonly"></simple-select>
  28. </td>
  29. <td>
  30. <u--input v-model="item.inspectionMethod" :readonly="readonly"></u--input>
  31. </td>
  32. <td v-if="! readonly">
  33. <u-button text="删除" type="error" @tap="del(item)"></u-button>
  34. </td>
  35. </tr>
  36. </table>
  37. </div>
  38. </template>
  39. <script>
  40. import simpleSelect from "@/components/simpleSelect.vue";
  41. import { genKey, clone, deleteListField } from "@/utils/tools";
  42. export default {
  43. components: {simpleSelect},
  44. props: {
  45. title: {
  46. type: String,
  47. required: false,
  48. default: "",
  49. },
  50. dataList: {
  51. type: Array,
  52. required: false,
  53. default: () => {return []}
  54. },
  55. readonly: {
  56. type: Boolean,
  57. required: false,
  58. default: false,
  59. },
  60. enumId: {
  61. type: String,
  62. required: true,
  63. },
  64. },
  65. data() {
  66. return {
  67. listLoading: false,
  68. acTableData: this.dataList,
  69. };
  70. },
  71. mounted() {
  72. this.acTableData = this.dataList
  73. },
  74. watch: {
  75. dataList(n) {
  76. this.acTableData = this.dataList
  77. }
  78. },
  79. methods: {
  80. add() {
  81. // inspectionItemId integer($int32)
  82. // inspectionMethod string
  83. // inspectionValue string
  84. // qcQualityInspectionId integer($int32)
  85. // singleConclusion string
  86. const d = {
  87. inspectionItemId: null, // 检测项目 ids
  88. inspectionMethod: null, // 检验方法
  89. inspectionValue: null, // 值
  90. singleConclusion: null, // 符合/不符合
  91. key: genKey('aqct')
  92. }
  93. this.acTableData.push(d)
  94. },
  95. del(data) {
  96. this.acTableData = this.acTableData.filter(d => d.key !== data.key)
  97. },
  98. getTableData() {
  99. const list = clone(this.acTableData)
  100. deleteListField(list, 'key')
  101. return list
  102. },
  103. clear() {
  104. this.acTableData = []
  105. }
  106. },
  107. };
  108. </script>
  109. <style scoped lang="scss">
  110. .act_header {
  111. display: flex;
  112. flex-direction: column;
  113. justify-content: center;
  114. align-items: center;
  115. }
  116. .row {
  117. margin-bottom: 5px;
  118. }
  119. </style>