list.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view class="list u-p-b-20 u-p-l-20 u-p-r-20" ref="tableRef">
  3. <view class="list-box">
  4. <SwipeItem :list="list" :buttons="options" @action="actionClick" ref="swipeItem" :marginB="20">
  5. <template v-slot="{ item }">
  6. <view class="item" @tap.stop="goDetail(item)" style="border: 1px solid #fff;">
  7. <view class="u-m-b-10 checkbox_box" v-if="showCheckbox">
  8. <u-checkbox @change="checkboxChange($event,item)" v-model="item.checked" class="checkbox"
  9. @tap.stop shape="circle"></u-checkbox>
  10. </view>
  11. <view class="item-cell" v-for="(column,i) in columnList" :key="i">
  12. <template v-if="column.jnpfKey != 'table'">
  13. <text class="item-cell-label">{{column.label}}:</text>
  14. <text class="item-cell-content"
  15. v-if="['calculate','inputNumber'].includes(column.jnpfKey)">
  16. {{toThousands(item[column.prop],column)}}
  17. </text>
  18. <text class="item-cell-content text-primary"
  19. v-else-if="column.jnpfKey == 'relationForm'"
  20. @click.stop="relationFormClick(item,column)">
  21. {{item[column.prop]}}
  22. </text>
  23. <view class="item-cell-content" v-else-if="column.jnpfKey == 'sign'">
  24. <JnpfSign v-model="item[column.prop]" align="left" detailed />
  25. </view>
  26. <view class="item-cell-content" v-else-if="column.jnpfKey == 'signature'">
  27. <JnpfSignature v-model="item[column.prop]" align="left" detailed />
  28. </view>
  29. <view class="item-cell-content" v-else-if="column.jnpfKey == 'uploadImg'" @click.stop>
  30. <JnpfUploadImg v-model="item[column.prop]" detailed simple
  31. v-if="item[column.prop]&&item[column.prop].length" />
  32. </view>
  33. <!-- #ifndef APP-HARMONY -->
  34. <view class="item-cell-content" v-else-if="column.jnpfKey == 'uploadFile'" @click.stop>
  35. <JnpfUploadFile v-model="item[column.prop]" detailed
  36. v-if="item[column.prop]&&item[column.prop].length" align="left" />
  37. </view>
  38. <!-- #endif -->
  39. <!-- #ifdef APP-HARMONY -->
  40. <view class="item-cell-content" v-else-if="column.jnpfKey == 'uploadFile'" @click.stop>
  41. <JnpfUploadFileH v-model="item[column.prop]" detailed
  42. v-if="item[column.prop]&&item[column.prop].length" align="left" />
  43. </view>
  44. <!-- #endif -->
  45. <view class="item-cell-content" v-else-if="column.jnpfKey == 'rate'">
  46. <JnpfRate v-model="item[column.prop]" :max="column.count"
  47. :allowHalf="column.allowHalf" disabled />
  48. </view>
  49. <view class="item-cell-content item-cell-slider" v-else-if="column.jnpfKey == 'slider'">
  50. <JnpfSlider v-model="item[column.prop]" :min="column.min" :max="column.max"
  51. :step="column.step" disabled />
  52. </view>
  53. <view class="item-cell-content" v-else-if="column.jnpfKey == 'input'">
  54. <JnpfInput v-model="item[column.prop]" detailed showOverflow
  55. :useMask="column.useMask" :maskConfig="column.maskConfig" align='left' />
  56. </view>
  57. <text class="item-cell-content" v-else>{{item[column.prop]}}</text>
  58. </template>
  59. <tableCell v-else @click.stop class="tableCell" ref="tableCell" :label="column.label"
  60. :childList="item[column.prop]" :children="column.children" :pageLen="3"
  61. @cRelationForm="relationFormClick" :key="item.id+i">
  62. </tableCell>
  63. </view>
  64. <view class="item-cell" v-if="config.enableFlow==1">
  65. <text class="item-cell-label">审批状态:</text>
  66. <text :style="{color:useDefine.getFlowStatusColor(item.flowState)}">
  67. {{useDefine.getFlowStatusContent(item.flowState)}}
  68. </text>
  69. </view>
  70. </view>
  71. </template>
  72. </SwipeItem>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. import {
  78. useDefineSetting
  79. } from '@/utils/useDefineSetting';
  80. import tableCell from '../tableCell.vue'
  81. import SwipeItem from "@/components/SwipeItem/index"
  82. export default {
  83. emits: ['selectCheckbox', 'handleClick', 'handleMoreClick', 'goDetail', 'relationFormClick', 'update:modelValue'],
  84. components: {
  85. tableCell,
  86. SwipeItem
  87. },
  88. props: ['config', 'list', 'columnList', 'actionOptions', 'showSelect', 'checkedAll', 'modelValue', 'isMoreBtn',
  89. 'customBtnsList'
  90. ],
  91. data() {
  92. return {
  93. selectData: [],
  94. useDefine: useDefineSetting()
  95. }
  96. },
  97. watch: {
  98. checkedAll: {
  99. handler(val) {
  100. this.handleCheckAll()
  101. },
  102. immediate: true
  103. }
  104. },
  105. computed: {
  106. options() {
  107. if (!this.customBtnsList?.length) return this.actionOptions;
  108. return [{
  109. text: this.$t('common.moreText'),
  110. value: 'more',
  111. style: {
  112. backgroundColor: '#007aff'
  113. }
  114. },
  115. ...this.actionOptions,
  116. ];
  117. },
  118. showCheckbox() {
  119. return this.showSelect
  120. }
  121. },
  122. methods: {
  123. /* 关联表单操作 */
  124. relationFormClick(item, column) {
  125. this.$emit('relationFormClick', item, column)
  126. },
  127. /* 跳转详情 */
  128. goDetail(item) {
  129. this.$emit('goDetail', item)
  130. },
  131. actionClick(data) {
  132. const {
  133. index,
  134. value
  135. } = data
  136. if (value === 'remove') return this.$emit('handleClick', index)
  137. if (value === 'more') return this.$emit('handleMoreClick', index)
  138. },
  139. /* 列表选择框 */
  140. checkboxChange(e, item) {
  141. const isSelected = e.value;
  142. const selectedItemsSet = new Set(this.selectData.map(selectedItem => {
  143. return selectedItem.id;
  144. }));
  145. if (isSelected) {
  146. selectedItemsSet.add(item.id);
  147. } else {
  148. selectedItemsSet.delete(item.id);
  149. }
  150. this.selectData = [...selectedItemsSet.values()].map(id => {
  151. return this.list.find(listItem => listItem.id === id);
  152. });
  153. this.$emit('selectCheckbox', this.selectData);
  154. },
  155. /* 全部选中 */
  156. handleCheckAll() {
  157. this.selectData = []
  158. if (this.checkedAll) this.selectData = this.list.filter(o => o.checked)
  159. this.$emit('selectCheckbox', this.selectData)
  160. },
  161. /* 千分位操作 */
  162. toThousands(val, column) {
  163. if (val) {
  164. let valList = val.toString().split('.')
  165. let num = Number(valList[0])
  166. let newVal = column.thousands ? num.toLocaleString() : num
  167. return valList[1] ? newVal + '.' + valList[1] : newVal
  168. } else {
  169. return val
  170. }
  171. }
  172. }
  173. }
  174. </script>
  175. <style lang="scss">
  176. .list {
  177. .list_box {
  178. .item {
  179. padding: 0;
  180. .checkbox_box {
  181. width: 60rpx;
  182. height: 46rpx;
  183. position: relative;
  184. .checkbox {
  185. position: absolute;
  186. top: 6rpx;
  187. left: 8rpx;
  188. z-index: 9999;
  189. }
  190. }
  191. }
  192. }
  193. }
  194. .right-option-box {
  195. display: flex;
  196. width: max-content;
  197. .right-option {
  198. width: 144rpx;
  199. height: 100%;
  200. font-size: 16px;
  201. color: #fff;
  202. background-color: #dd524d;
  203. display: flex;
  204. align-items: center;
  205. justify-content: center;
  206. }
  207. .more-option {
  208. background-color: #1890ff;
  209. }
  210. }
  211. </style>