selectData.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <div>
  3. <van-action-sheet class="bigsheetbox" v-model="show" position="bottom" title="选择资料">
  4. <van-row>
  5. <van-col span="24">
  6. <!-- <van-search v-model="searchVal" placeholder="请输入搜索关键词" /> -->
  7. <form action="/">
  8. <van-search v-model="searchVal" placeholder="请输入搜索关键词" clearable @input="onSearch" />
  9. </form>
  10. </van-col>
  11. </van-row>
  12. <van-row class="rowclss">
  13. <van-col span="24">
  14. <van-collapse v-model="activeNames" @change="checkedHandler">
  15. <van-checkbox-group v-model="result" >
  16. <van-collapse-item
  17. v-for="item in peopleListCpoy"
  18. :name="item.id"
  19. :key="item.id"
  20. :title="`${item.title}-(${item.orgName})`"
  21. >
  22. <!-- :title="item.defaultCause" -->
  23. <template #right-icon>
  24. <van-checkbox :name="item.id" > </van-checkbox>
  25. </template>
  26. <van-row>
  27. <van-col class="colCls" span="24" v-for="i in item.fileList" :key="i.name">
  28. <van-tag type="primary" class="tagCls" plain @click="tagHandler(i)">{{ i.name }}</van-tag>
  29. </van-col>
  30. </van-row>
  31. </van-collapse-item>
  32. </van-checkbox-group>
  33. </van-collapse>
  34. </van-col>
  35. </van-row>
  36. <van-row class="bottomdiv">
  37. <van-col span="24">
  38. <van-button class="btns" size="large" type="info" @click="submitHandler">确定</van-button>
  39. </van-col>
  40. </van-row>
  41. </van-action-sheet>
  42. </div>
  43. </template>
  44. <script>
  45. import { deptTreeList } from '@/api/toConsult.js'
  46. import { materialsFileList } from '@/api/training.js'
  47. import OrgTree from '@/components/orgTree'
  48. import { Toast } from 'vant'
  49. export default {
  50. name: 'SocAppIndex',
  51. components: {
  52. OrgTree
  53. },
  54. props: {
  55. organizationId: {
  56. //机构ID
  57. },
  58. //培训资料数量
  59. listLength: {
  60. type: Number
  61. }
  62. },
  63. data() {
  64. return {
  65. activeNames: [],
  66. result: [],
  67. orgId: this.organizationId || '',
  68. show: false,
  69. value1: '',
  70. showcascader: false,
  71. cascaderValue: '',
  72. loading: false,
  73. options: [], //机构列表
  74. peoplesId: [], //资料ID集合
  75. searchVal: '', //搜索值
  76. peopleList: [], //资料列表
  77. peopleListCpoy: [], //资料列表2
  78. orgName: '', //机构名称
  79. peoples: '' //资料列表
  80. }
  81. },
  82. watch: {
  83. organizationId(val) {
  84. this.orgId = val + ''
  85. this.getSelectData()
  86. },
  87. //监听弹框是否打开
  88. show(val) {
  89. if (val) {
  90. this.getSelectData()
  91. }
  92. },
  93. //监听资料数组变化
  94. userList(val) {
  95. this.peoplesId = []
  96. this.$set(this.$data, 'peoples', val.map(item => item.userName).join(','))
  97. val.map(item => {
  98. this.peoplesId.push(item.userId)
  99. })
  100. }
  101. },
  102. created() {},
  103. mounted() {},
  104. methods: {
  105. onLoad() {},
  106. //获取资料
  107. getSelectData() {
  108. materialsFileList({ orgId: this.orgId, pageNum: 1, pageSize: 100000 }).then(res => {
  109. let { code, rows, msg } = res
  110. if (code == 200) {
  111. rows.forEach(item => {
  112. if (item.fileList && item.fileList.length > 0) {
  113. item.fileList = item.fileList.map(i => {
  114. i = JSON.parse(i)
  115. return i
  116. })
  117. }
  118. })
  119. this.peopleList = rows
  120. this.peopleListCpoy = JSON.parse(JSON.stringify(rows))
  121. }
  122. })
  123. },
  124. onSearch(val) {
  125. this.peopleListCpoy = this.peopleList.filter(item => {
  126. if (item.title.indexOf(val) != -1 || item.orgName.indexOf(val) != -1) {
  127. return item
  128. }
  129. })
  130. },
  131. onCancel() {
  132. this.searchVal = ''
  133. this.peopleListCpoy = this.peopleList
  134. },
  135. submitHandler() {
  136. let list = []
  137. this.peopleListCpoy.filter(item => {
  138. this.result.forEach(r => {
  139. if (r == item.id) {
  140. list.push(...item.fileList)
  141. }
  142. })
  143. })
  144. // this.peoples = list.map(item => item.name).join(',')
  145. if (list.length + this.listLength > 5) {
  146. return Toast('资料附件数量不能超过5个,请修改!')
  147. }
  148. this.$set(this.$data, 'peoples', list.map(item => item.name).join(','))
  149. // 抛出已选择资料信息
  150. this.$emit('dataList', list)
  151. this.show = false
  152. },
  153. //复选框单选
  154. // changeCheckBox(list) {
  155. // if (list && list.length > 1) {
  156. // this.result = [list[list.length - 1]]
  157. // }
  158. // },
  159. checkedHandler(id) {
  160. this.result=id
  161. },
  162. tagHandler(i) {
  163. this.openFilePreview(i)
  164. // const filePath = `${process.env.NODE_ENV === 'development' ? '/dev' : window.origin}${i.url}`
  165. // const tempLink = document.createElement('a')
  166. // tempLink.style.display = 'none'
  167. // tempLink.href = filePath
  168. // tempLink.setAttribute('download', i.name)
  169. // tempLink.setAttribute('target', '_blank')
  170. // document.body.appendChild(tempLink)
  171. // tempLink.click()
  172. // document.body.removeChild(tempLink)
  173. },
  174. clickHandler() {
  175. console.log('哈哈哈哈')
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="scss" scoped>
  181. .van-action-sheet {
  182. min-height: 90%;
  183. }
  184. .btns {
  185. width: 100%;
  186. height: 90px;
  187. }
  188. .bottomdiv {
  189. width: 100%;
  190. bottom: 0%;
  191. position: absolute;
  192. margin-top: 20px;
  193. z-index: 2000;
  194. padding-bottom:calc(0 + env(safe-area-inset-bottom));
  195. }
  196. .rowclss{
  197. // height: 1050px;
  198. height: calc(100vh - 180px);
  199. overflow: scroll;
  200. }
  201. .bigsheetbox {
  202. height: calc(100vh - 100px);
  203. }
  204. .van-field__control {
  205. padding-right: 20px;
  206. }
  207. .line {
  208. width: 100%;
  209. height: 3px;
  210. background-color: #1989fa;
  211. }
  212. .colCls {
  213. display: flex;
  214. .tagCls {
  215. margin-top: 10px;
  216. }
  217. }
  218. </style>