reagentQualitative.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div>
  3. <div class="reagentQualitative">
  4. <el-row type="flex">
  5. <el-col class="button">
  6. <div class="title">*</div>
  7. <div v-if="isRead" />
  8. <div v-else>
  9. <el-button type="primary" size="mini" icon="ibps-icon-add" @click="handleAdd"> 添加</el-button>
  10. <el-button type="primary" size="mini" icon="ibps-icon-copy" @click="handleCopy"> 复制</el-button>
  11. <el-button type="danger" size="mini" icon="ibps-icon-remove" @click="handleDelete"> 删除</el-button>
  12. </div>
  13. </el-col>
  14. </el-row>
  15. <el-row type="flex">
  16. <el-col>
  17. <el-table ref="external" :data="reagentBatchDataFilter" :span-method="objectSpanMethod" @selection-change="handleSelectionChange">
  18. <el-table-column type="selection" width="55" />
  19. <el-table-column :label="formData.yiYuan === '深圳肿瘤' ? '病理号':'样品序号 (条码号)'" prop="biaoBenHao">
  20. <template slot-scope="{row}">
  21. <el-input v-if="!isRead" v-model="row.biaoBenHao" size="mini" maxlength="32" placeholder="请输入" />
  22. <span v-else>{{ row.biaoBenHao }}</span>
  23. </template>
  24. </el-table-column>
  25. <el-table-column label="新批号" prop="xinJieGuo">
  26. <template slot-scope="{row}">
  27. <el-input v-if="!isRead" v-model="row.xinJieGuo" size="mini" maxlength="32" placeholder="请输入" />
  28. <span v-else>{{ row.xinJieGuo }}</span>
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="旧批号" prop="jiuJieGuo">
  32. <template slot-scope="{row}">
  33. <el-input v-if="!isRead" v-model="row.jiuJieGuo" size="mini" maxlength="32" placeholder="请输入" />
  34. <span v-else>{{ row.jiuJieGuo }}</span>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="是否相符" prop="xiangFu">
  38. <template slot-scope="{row}">
  39. <el-radio-group v-model="row.xiangFu" :disabled="isRead">
  40. <el-radio label="是">是</el-radio>
  41. <el-radio label="否">否</el-radio>
  42. </el-radio-group>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="可接受范围(≥80%)" prop="biaoZhun">
  46. <template slot-scope="{row}">
  47. <el-input v-if="!isRead" v-model="row.biaoZhun" size="mini" maxlength="32" placeholder="请输入" @input="handleInput" />
  48. <span v-else>{{ row.biaoZhun }}</span>
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. <el-pagination
  53. layout="total,sizes,prev, pager, next,jumper"
  54. :current-page="requestPage.pageNo"
  55. :page-size="requestPage.limit"
  56. :page-sizes="[10,15,20,30,50,100]"
  57. :total="reagentBatchData.length"
  58. @size-change="handleSizeChange"
  59. @current-change="handleCurrentChange"
  60. />
  61. </el-col>
  62. </el-row>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import { cloneDeep } from 'lodash'
  68. export default {
  69. props: {
  70. formData: {
  71. type: Object,
  72. default: () => {}
  73. },
  74. readonly: {
  75. type: Boolean,
  76. default: false
  77. },
  78. params: {
  79. type: Object,
  80. default: () => {}
  81. }
  82. },
  83. data () {
  84. return {
  85. reagentBatchData: [],
  86. disabled: false,
  87. requestPage: {
  88. limit: 10,
  89. pageNo: 1
  90. },
  91. multipleSelection: [],
  92. isRead: false
  93. }
  94. },
  95. computed: {
  96. reagentBatchDataFilter () {
  97. return this.reagentBatchData.slice((this.requestPage.pageNo - 1) * (this.requestPage.limit), (this.requestPage.pageNo - 1) * (this.requestPage.limit) + this.requestPage.limit)
  98. }
  99. },
  100. watch: {
  101. 'formData.sjghyzjlbbbzb': {
  102. handler (value, old) {
  103. if (value && value.length) {
  104. this.reagentBatchData = value
  105. }
  106. },
  107. immediate: true
  108. },
  109. reagentBatchData: {
  110. handler (value, old) {
  111. this.$emit('change-data', 'sjghyzjlbbbzb', value)
  112. },
  113. deep: true
  114. }
  115. },
  116. mounted () {
  117. this.isRead = this.readonly || this.params.nodeId === 'Activity_1envuj2'
  118. },
  119. methods: {
  120. handleInput (e) {
  121. this.reagentBatchData.forEach(item => {
  122. item.biaoZhun = e
  123. })
  124. },
  125. objectSpanMethod ({ row, column, rowIndex, columnIndex }) {
  126. if (columnIndex === 5) {
  127. // 获取当前单元格的值
  128. const currentValue = row[column.property]
  129. // 获取上一行相同列的值
  130. const preRow = this.reagentBatchData[rowIndex - 1]
  131. const preValue = preRow ? preRow[column.property] : null
  132. // 如果当前值和上一行的值相同,则将当前单元格隐藏
  133. if (currentValue === preValue) {
  134. return { rowspan: 0, colspan: 0 }
  135. } else {
  136. // 否则计算当前单元格应该跨越多少行
  137. let rowspan = 1
  138. for (let i = rowIndex + 1; i < this.reagentBatchData.length; i++) {
  139. const nextRow = this.reagentBatchData[i]
  140. const nextValue = nextRow[column.property]
  141. if (nextValue === currentValue) {
  142. rowspan++
  143. } else {
  144. break
  145. }
  146. }
  147. return { rowspan, colspan: 1 }
  148. }
  149. }
  150. },
  151. handleSelectionChange (val) {
  152. this.multipleSelection = val
  153. },
  154. handleAdd () {
  155. this.reagentBatchData.push({
  156. biaoBenHao: '',
  157. xinJieGuo: '',
  158. jiuJieGuo: '',
  159. xiangFu: '是',
  160. biaoZhun: this.reagentBatchData.length > 0 ? this.reagentBatchData[0].biaoZhun : '' // 如果已有数据,则添加biaozhun的值应该是统一的
  161. })
  162. },
  163. // 删除
  164. handleDelete () {
  165. this.$confirm('确定删除当前选中数据?', '提示', {
  166. confirmButtonText: '确定',
  167. cancelButtonText: '取消',
  168. type: 'warning'
  169. }).then(() => {
  170. if (this.multipleSelection.length > 0) {
  171. this.reagentBatchData = this.reagentBatchData.filter(row => !this.multipleSelection.includes(row))
  172. } else {
  173. this.$message.warning('请选择数据')
  174. }
  175. })
  176. },
  177. // 复制
  178. handleCopy () {
  179. if (this.multipleSelection.length > 0) {
  180. this.reagentBatchData = this.reagentBatchData.concat(cloneDeep(this.multipleSelection))
  181. } else {
  182. this.$message.warning('请选择数据')
  183. }
  184. },
  185. // 当前页码改变
  186. handleCurrentChange (val) {
  187. this.requestPage.pageNo = val
  188. },
  189. // 页码选择器改变
  190. handleSizeChange (val) {
  191. this.requestPage.limit = val
  192. this.requestPage.pageNo = 1
  193. }
  194. }
  195. }
  196. </script>
  197. <style lang="scss" scoped>
  198. .reagentQualitative{
  199. margin-bottom: 20px;
  200. .button{
  201. display: flex;
  202. justify-content: space-between;
  203. padding: 0px 0px 0px 15px;
  204. background: #f0ffff;
  205. .title {
  206. color: red;
  207. font-size: 12px;
  208. font-weight: bold;
  209. margin-bottom: 0;
  210. }
  211. .el-button {
  212. margin: 0;
  213. }
  214. }
  215. }
  216. // ::v-deep .el-table--border td, .el-table--border th, .el-table__body-wrapper .el-table--border .is-scrolling-left .el-table__fixed {
  217. // border-right: 1px solid rgba(255, 0, 0, 0)!important;
  218. // }
  219. </style>