应无所住,而生其心
排名
1
文章
860
粉丝
112
评论
163
net core webapi post传递参数
庸人 : 确实坑哈,我也是下班好了好几次,发现后台传递对象是可以的,但...
百度编辑器自定义模板
庸人 : 我建议换个编辑器,因为现在百度富文本已经停止维护了,用tinymec...
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术

vue elementui 基础表格布局,基础表格+条件+搜索框布局,类型处理,父子组件方法调用

5051人阅读 2020/6/6 10:20 总访问:5182638 评论:0 收藏:0 手机
分类: 前端

基础表格+条件+搜索框布局

效果如下:

代码如下:

  1. <template>
  2. <div class="app-container">
  3. <el-card class="box-card">
  4. <div slot="header" class="clearfix">
  5. <div class="toolbar">
  6. <div class="item-left">
  7. <el-button type="primary" icon="el-icon-plus">添加</el-button>
  8. </div>
  9. <div class="item-right">
  10. <div class="search">
  11. <el-select v-model="pageParam.txid" placeholder="请选择课程体系" style="width: 140px;">
  12. <el-option label="所有课程体系" value="" />
  13. <el-option v-for="op in tixilist" :key="op.id" :label="op.name" :value="op.id" />
  14. </el-select>
  15. <el-select v-model="pageParam.status" placeholder="请选择状态" style="width: 120px;">
  16. <el-option label="所有状态" :value="-1" />
  17. <el-option label="禁用" :value="0" />
  18. <el-option label="启用" :value="1" />
  19. </el-select>
  20. <el-select v-model="pageParam.type" placeholder="请选择类型" style="width: 120px;display: none;">
  21. <el-option label="所有类型" :value="-1" />
  22. <el-option label="评估" :value="0" />
  23. <el-option label="实验" :value="1" />
  24. </el-select>
  25. <el-input v-model="pageParam.key" placeholder="请输入内容" class="input-with-select"
  26. style="width: 240px;" />
  27. <el-button slot="append" icon="el-icon-search" type="primary" @click="loadpagelist()">搜索
  28. </el-button>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. <div>
  34. <el-table :data="courseList" stripe style="width: 100%" empty-text="暂无数据">
  35. <el-table-column type="index" label="No" width="50" />
  36. <el-table-column prop="courseName" label="课程名称" />
  37. <el-table-column prop="tixi.name" label="课程体系" width="150" />
  38. <el-table-column prop="courseType" label="课程类型" width="150">
  39. <template slot-scope="scope">
  40. <div>
  41. <span v-if="scope.row.courseType == 0">评估</span>
  42. <span v-else-if="scope.row.courseType == 1">实验</span>
  43. </div>
  44. </template>
  45. </el-table-column>
  46. <el-table-column prop="isEnable" label="状态" width="80">
  47. <template slot-scope="scope">
  48. <div>
  49. <span v-if="scope.row.isEnable">启用</span>
  50. <span v-else style="color: lightpink;">禁用</span>
  51. </div>
  52. </template>
  53. </el-table-column>
  54. <el-table-column prop="addManName" label="创建人" width="80" />
  55. <el-table-column prop="addTime" label="创建时间" width="120"
  56. :formatter="(r, c, v) => { return $utils.colDateFormat(v, 'YYYY-MM-DD') }" />
  57. <el-table-column prop="courseVersion" label="版本号" width="120" />
  58. <el-table-column label="操作" width="180" fixed="right">
  59. <div slot-scope="scope">
  60. <el-button size="mini" type="text" @click="editcourse(scope.row)">编辑</el-button>
  61. <el-button size="mini" type="text" @click="editchapter(scope.row)">章节管理</el-button>
  62. <el-button v-if="type === 1" size="mini" type="text" @click="jumpLab(scope.row)">实验手册
  63. </el-button>
  64. <el-button v-if="type === 0" size="mini" type="text" @click="jumpknow(scope.row)">知识点
  65. </el-button>
  66. </div>
  67. </el-table-column>
  68. </el-table>
  69. <el-pagination background layout="prev, pager, next" :total="pageParam.dataCount"
  70. :page-size="pageParam.pageSize" :current-page="pageParam.pageIndex"
  71. @current-change="currentChange" />
  72. </div>
  73. </el-card>
  74. </div>
  75. </template>
  76. <script>
  77. import Tinymce from '@/components/Tinymce'
  78. export default {
  79. name: 'Mycourseindex',
  80. components: {
  81. Tinymce
  82. },
  83. props: {
  84. type: { // 类型 实验、评估
  85. type: [Number],
  86. required: false,
  87. default: 0
  88. }
  89. },
  90. data() {
  91. return {
  92. editorToolBar: [
  93. 'bold italic underline strikethrough alignleft aligncenter alignright outdent indent blockquote undo redo removeformat subscript superscript code codesample'
  94. ],
  95. courseList: [],
  96. tixilist: [],
  97. pageParam: {
  98. pageIndex: 1,
  99. pageSize: 15,
  100. dataCount: 0,
  101. key: '',
  102. type: -1,
  103. status: -1,
  104. txid: ''
  105. },
  106. }
  107. },
  108. created() {
  109. },
  110. mounted() { },
  111. methods: {
  112. currentChange(curentIndex) {
  113. // const self = this
  114. // self.pageParam.pageIndex = curentIndex
  115. // self.loadpagelist()
  116. },
  117. }
  118. }
  119. </script>
  120. <style lang="scss">
  121. .myuploader {
  122. .el-upload {
  123. border: solid 1px #eee;
  124. border-radius: 6px;
  125. cursor: pointer;
  126. position: relative;
  127. overflow: hidden;
  128. }
  129. .el-upload:hover {
  130. border-color: #409EFF;
  131. }
  132. .avatar-uploader-icon {
  133. font-size: 28px;
  134. color: #8c939d;
  135. width: 80px;
  136. height: 80;
  137. line-height: 80px;
  138. text-align: center;
  139. }
  140. .avatar {
  141. width: 80px;
  142. height: 80px;
  143. display: block;
  144. }
  145. }
  146. </style>

有逻辑代码,接口调用,弹窗查看详情,图片上传,图片预览,完善一些的

页面:

  1. <!-- 教师反馈 -->
  2. <template>
  3. <div class="app-container">
  4. <el-card class="box-card">
  5. <div slot="header" class="clearfix">
  6. <div class="toolbar">
  7. <div class="item-left">
  8. <el-button type="primary" size="small" icon="el-icon-plus" @click="openFeedbackDialog()">反馈
  9. </el-button>
  10. </div>
  11. <div class="item-right">
  12. <div class="search">
  13. <!-- <el-select v-model="pageParam.txid" placeholder="请选择课程体系" style="width: 140px;">
  14. <el-option label="所有课程体系" value="" />
  15. <el-option v-for="op in tixilist" :key="op.id" :label="op.name" :value="op.id" />
  16. </el-select>
  17. <el-select v-model="pageParam.status" placeholder="请选择状态" style="width: 120px;">
  18. <el-option label="所有状态" :value="-1" />
  19. <el-option label="禁用" :value="0" />
  20. <el-option label="启用" :value="1" />
  21. </el-select> -->
  22. <!-- <el-select v-model="pageParam.type" placeholder="请选择类型" style="width: 120px;display: none;">
  23. <el-option label="所有类型" :value="-1" />
  24. <el-option label="评估" :value="0" />
  25. <el-option label="实验" :value="1" />
  26. </el-select> -->
  27. <!-- <el-select v-model="queryParms.feedbackType" size="small" class="query-condition" filterable
  28. @change="search">
  29. <el-option label="反馈类型" value="" />
  30. <el-option v-for="item in feedbackTypes" :key="item.feedbackType"
  31. :label="item.feedbackName" :value="item.feedbackType" />
  32. </el-select> -->
  33. <el-select
  34. v-model="queryParms.dealType"
  35. size="small"
  36. class="query-condition"
  37. filterable
  38. @change="getData()"
  39. >
  40. <el-option label="处理类型" value="" />
  41. <el-option
  42. v-for="item in dealTypes"
  43. :key="item.dealType"
  44. :label="item.dealTypeName"
  45. :value="item.dealType"
  46. />
  47. </el-select>
  48. <el-select
  49. v-model="queryParms.feedbackType"
  50. size="small"
  51. class="query-condition"
  52. filterable
  53. @change="getData()"
  54. >
  55. <el-option label="反馈类型" value="" />
  56. <el-option
  57. v-for="item in feedbackTypes"
  58. :key="item.feedbackType"
  59. :label="item.feedbackName"
  60. :value="item.feedbackType"
  61. />
  62. </el-select>
  63. <el-input
  64. v-model="queryParms.QueryName"
  65. size="small"
  66. placeholder="请输入内容"
  67. class="input-with-select"
  68. style="width: 191px;"
  69. />
  70. <el-button
  71. slot="append"
  72. size="small"
  73. icon="el-icon-search"
  74. type="primary"
  75. @click="getData()"
  76. >搜索
  77. </el-button>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. <div>
  83. <el-table v-loading="loading" :data="dataList">
  84. <el-table-column label="NO" type="index" width="50" fixed="left" />
  85. <!-- <el-table-column label="姓名" prop="userShowName" width="80" />
  86. <el-table-column label="账号" prop="userName" /> -->
  87. <el-table-column label="描述" prop="feedbackDescribe" />
  88. <el-table-column prop="feedbackType" label="类型" width="100">
  89. <template slot-scope="scope">
  90. <el-tag v-if="scope.row.feedbackType == 1" type="danger">系统问题</el-tag>
  91. <el-tag v-if="scope.row.feedbackType == 2" type="warning">内容问题</el-tag>
  92. <el-tag v-if="scope.row.feedbackType == 3">我要吐槽</el-tag>
  93. </template>
  94. </el-table-column>
  95. <el-table-column prop="dealType" label="处理" width="100">
  96. <template slot-scope="scope">
  97. <el-tag v-if="scope.row.dealType == 0" type="warning">未处理</el-tag>
  98. <el-tag v-if="scope.row.dealType == 1" type="success">已处理</el-tag>
  99. <el-tag v-if="scope.row.dealType == 2" type="info">已驳回</el-tag>
  100. <el-tag v-if="scope.row.dealType == 3" type="warning">不予处理</el-tag>
  101. </template>
  102. </el-table-column>
  103. <!-- <el-table-column prop="dataFromType" label="来源" width="80">
  104. <template slot-scope="scope">
  105. <el-tag v-if="scope.row.dataFromType == 0" type="danger">未知</el-tag>
  106. <el-tag v-if="scope.row.dataFromType == 1" type="warning">实验</el-tag>
  107. <el-tag v-if="scope.row.dataFromType == 2" type="success">评估</el-tag>
  108. </template>
  109. </el-table-column> -->
  110. <!-- <el-table-column label="地址" prop="feedbackPath" width="100" show-overflow-tooltip /> -->
  111. <el-table-column label="反馈时间" width="115">
  112. <template slot-scope="{ row }">
  113. {{ $utils.colDateFormat(row.createTime, "YYYY-MM-DD") }}
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="操作" width="70" :align="left" fixed="right">
  117. <template slot-scope="{ row }" style="text-align:center">
  118. <el-button size="mini" style="margin-left: -10px;" @click="showDetais(row)">详情</el-button>
  119. <!-- <el-link @click="showFeedbackDialog(row.id)">处理</el-link> -->
  120. <!-- <el-link style="margin-left:10px" @click="showDetais(row)">详情</el-link> -->
  121. </template>
  122. </el-table-column>
  123. </el-table>
  124. <el-pagination
  125. background
  126. layout="total,prev, pager, next"
  127. :total="queryParms.dataCount"
  128. :page-size="queryParms.PageSize"
  129. :current-page="queryParms.PageIndex"
  130. @current-change="currentChange"
  131. />
  132. </div>
  133. </el-card>
  134. <el-dialog title="详情" :visible.sync="detailsDialogVisible" width="30%" :before-close="handleClose">
  135. <div style="margin-top:9px">
  136. <span style="font-weight:800"> 反馈内容:</span>
  137. <span>{{ details.feedbackDescribe }}</span>
  138. </div>
  139. <div style="margin-top:9px">
  140. <span style="font-weight:800"> 处理状态:</span>
  141. <el-tag v-if="details.dealType == 0" type="warning">未处理</el-tag>
  142. <el-tag v-if="details.dealType == 1" type="success">已处理</el-tag>
  143. <el-tag v-if="details.dealType == 2" type="info">已驳回</el-tag>
  144. </div>
  145. <div v-if="details.dealingOpinion">
  146. <div style="margin-top:9px">
  147. <span style="font-weight:800"> 处理意见:</span>
  148. <span v-if="details.dealingOpinion">{{ details.dealingOpinion }}</span>
  149. </div>
  150. <div style="margin-top:9px">
  151. <span style="font-weight:800"> 处理人员:</span>
  152. <span>{{ details.dealUserName }}</span>
  153. </div>
  154. <div style="margin-top:9px">
  155. <span style="font-weight:800"> 处理时间:</span>
  156. <span>{{ details.dealTime }}</span>
  157. </div>
  158. </div>
  159. <div style="margin-top:9px;display:flex">
  160. <div style="font-weight:800"> 问题截图:</div>
  161. <div style="display:flex">
  162. <div
  163. v-for="(item, i) in details.feedbackImgs"
  164. :key="i + 'img'"
  165. style="margin-right:10px"
  166. class="img-waper"
  167. @click="onPreviewImg(i)"
  168. >
  169. <!-- 用id去显示图片,其实就是图片处理后的名称 -->
  170. <img
  171. style="cursor:pointer"
  172. :src="'/oss/api/ImageViewer/' + item.id + '.jpg?percent=0.6&quality=80&od=true'"
  173. width="70px"
  174. height="70px"
  175. >
  176. </div>
  177. </div>
  178. </div>
  179. <span slot="footer" class="dialog-footer">
  180. <el-button @click="detailsDialogVisible = false">取 消</el-button>
  181. <el-button type="primary" @click="detailsDialogVisible = false">确 定</el-button>
  182. </span>
  183. </el-dialog>
  184. <!-- 封装的弹窗组件 -->
  185. <FeedbackDialog ref="feedbackDialog" />
  186. <el-image-viewer
  187. v-if="showViewer"
  188. style="z-index:99999999"
  189. :on-close="closeViewer"
  190. :initial-index="initialIndex"
  191. :url-list="details.feedbackImgs.map(a => a.fileUrl)"
  192. />
  193. </div>
  194. </template>
  195. <script>
  196. import FeedbackDialog from './components/feedbackDialog.vue'
  197. import ElImageViewer from 'element-ui/packages/image/src/image-viewer'
  198. export default {
  199. name: 'Mycourseindex',
  200. components: {
  201. FeedbackDialog,
  202. ElImageViewer
  203. },
  204. props: {
  205. type: { // 类型 实验、评估
  206. type: [Number],
  207. required: false,
  208. default: 0
  209. }
  210. },
  211. data() {
  212. return {
  213. editorToolBar: [
  214. 'bold italic underline strikethrough alignleft aligncenter alignright outdent indent blockquote undo redo removeformat subscript superscript code codesample'
  215. ],
  216. loading: false,
  217. detailsDialogVisible: false,
  218. dataList: [], // 反馈列表
  219. tixilist: [],
  220. dealTypes: [
  221. { dealType: '0', dealTypeName: '未处理' },
  222. { dealType: '1', dealTypeName: '已处理' },
  223. { dealType: '2', dealTypeName: '已驳回' }
  224. ],
  225. feedbackTypes: [
  226. { feedbackType: '1', feedbackName: '系统问题' },
  227. { feedbackType: '2', feedbackName: '内容问题' },
  228. { feedbackType: '3', feedbackName: '我要吐槽' }
  229. ],
  230. queryParms: {
  231. pageIndex: 1,
  232. pageSize: 15,
  233. dataCount: 0,
  234. QueryName: '',
  235. key: '',
  236. type: -1,
  237. dealType: '',
  238. feedbackType: '',
  239. status: -1,
  240. txid: ''
  241. },
  242. showViewer: false,
  243. details: {
  244. feedbackDescribe: '',
  245. dealingOpinion: '',
  246. dealTime: '',
  247. dealUserName: '',
  248. dealType: '',
  249. feedbackImgs: []
  250. }
  251. }
  252. },
  253. created() {
  254. },
  255. mounted() {
  256. this.getData()
  257. },
  258. methods: {
  259. getData() {
  260. this.loading = true
  261. this.$http
  262. .get(
  263. '/education/api/TeacherFeedback/GetFeedbackListByUser',
  264. this.queryParms
  265. )
  266. .then((res) => {
  267. console.log(res)
  268. this.dataList = res.data.data
  269. this.loading = false
  270. this.queryParms.dataCount = res.data.dataCount
  271. })
  272. },
  273. // 打开图片预览
  274. onPreviewImg(i) {
  275. // 设置预览图片的索引
  276. this.initialIndex = i
  277. this.showViewer = true
  278. },
  279. // 关闭图片预览
  280. closeViewer() {
  281. this.showViewer = false
  282. },
  283. currentChange(curentIndex) {
  284. // const self = this
  285. // self.pageParam.pageIndex = curentIndex
  286. // self.loadpagelist()
  287. },
  288. showDetais(rowInp) {
  289. this.details.feedbackDescribe = rowInp.feedbackDescribe
  290. this.details.dealingOpinion = rowInp.dealingOpinion
  291. this.details.dealUserName = rowInp.dealUserName
  292. this.details.dealTime = rowInp.dealTime
  293. this.details.dealType = rowInp.dealType
  294. this.details.feedbackImgs = JSON.parse(rowInp.feedbackImgs)
  295. this.detailsDialogVisible = true
  296. },
  297. openFeedbackDialog() {
  298. // 调用子组件的方法打开弹窗
  299. this.$refs.feedbackDialog.openFeedbackDialog(this.dataFromType)
  300. }
  301. }
  302. }
  303. </script>
  304. <style lang="scss">
  305. .myuploader {
  306. .el-upload {
  307. border: solid 1px #eee;
  308. border-radius: 6px;
  309. cursor: pointer;
  310. position: relative;
  311. overflow: hidden;
  312. }
  313. .el-upload:hover {
  314. border-color: #409EFF;
  315. }
  316. .avatar-uploader-icon {
  317. font-size: 28px;
  318. color: #8c939d;
  319. width: 80px;
  320. height: 80;
  321. line-height: 80px;
  322. text-align: center;
  323. }
  324. .avatar {
  325. width: 80px;
  326. height: 80px;
  327. display: block;
  328. }
  329. }
  330. </style>

弹窗:

  1. <!-- 老师进行进行反馈 -->
  2. <!-- 问题反馈使用的弹窗 -->
  3. <template>
  4. <div>
  5. <!-- 弹窗start -->
  6. <div class="dialogContent">
  7. <el-dialog
  8. :visible.sync="dialogVisible"
  9. :show-close="false"
  10. width="700px"
  11. height="800px"
  12. :before-close="handleClose"
  13. >
  14. <div slot="title" class="dialog-footer">
  15. <div style="font-size:16px">
  16. 问题反馈
  17. </div>
  18. <div class="separateline" />
  19. </div>
  20. <div style="margin-top:-10px">
  21. <div style="display:flex">
  22. <div style="width:78px;color:#000">
  23. 问题类型:
  24. </div>
  25. <div>
  26. <el-radio v-model="feedbackType" label="1">系统问题</el-radio>
  27. <el-radio v-model="feedbackType" label="2">内容问题</el-radio>
  28. <el-radio v-model="feedbackType" label="3">我要吐槽</el-radio>
  29. </div>
  30. </div>
  31. <div style="display:flex;margin-top: 30px;">
  32. <div style="width:78px;color:#000;">
  33. 描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述:
  34. </div>
  35. <div style="flex-grow: 1">
  36. <el-input
  37. v-model="describe"
  38. type="textarea"
  39. style="width:100%"
  40. :rows="7"
  41. placeholder="请输入内容"
  42. />
  43. </div>
  44. </div>
  45. <div style="display:flex;margin-top: 30px;">
  46. <div style="width:78px;color:#000">
  47. 问题截图:
  48. </div>
  49. <div style="flex-grow: 1">
  50. <!-- 引用图片上传的组件 -->
  51. <UpLoadImg ref="upLoadImg" />
  52. </div>
  53. </div>
  54. </div>
  55. <span slot="footer" class="dialog-footer">
  56. <el-button size="small" @click="dialogVisible = false">我在想想</el-button>
  57. <el-button type="primary" size="small" @click="saveFeedback()">确定反馈</el-button>
  58. </span>
  59. </el-dialog>
  60. </div>
  61. <!-- 弹窗end -->
  62. </div>
  63. </template>
  64. <script>
  65. import UpLoadImg from './upLoadImg.vue'
  66. export default {
  67. // 组件名字
  68. name: 'FeedbackDialog',
  69. components: {
  70. UpLoadImg
  71. },
  72. // 组件参数
  73. props: {
  74. index: {
  75. type: Number,
  76. default: 0
  77. }
  78. },
  79. data() {
  80. return {
  81. feedbackType: '3',
  82. describe: '',
  83. dataFromType: 0,
  84. dialogVisible: false
  85. }
  86. },
  87. mounted() {
  88. // alert("组件内部加载好了"+this.dialogVisibleParameter)
  89. this.initPic()
  90. },
  91. // 组件方法
  92. methods: {
  93. initPic() {
  94. },
  95. // 模态框关闭前的事件
  96. handleClose(done) {
  97. },
  98. // 打开弹窗
  99. openFeedbackDialog(_dataFromType) {
  100. this.dialogVisible = true
  101. this.dataFromType = _dataFromType
  102. },
  103. // 清空一下反馈的数据,比如反馈成功之后清空一下,这样下次打开的时候不会让前面的数据还在
  104. clearFeedbackData() {
  105. this.feedbackType = '3'
  106. this.describe = ''
  107. // 清空上传的图片(通过调用子组件的方法实现,因为图片这块数据在子组件)
  108. this.$refs.upLoadImg.clearImgs()
  109. },
  110. // 确定反馈
  111. saveFeedback() {
  112. const _this = this
  113. if (!_this.describe) {
  114. this.$alert('请输入反馈内容')
  115. return
  116. }
  117. this.dialogVisible = false
  118. const classID = this.$route.query.classid
  119. // 从上传图片的子组件获取(调用子组件的方法获取)
  120. const imgJson = this.$refs.upLoadImg.getImgs()
  121. // 反馈回传的数据
  122. const feedbackData = {
  123. FeedbackImgs: JSON.stringify(imgJson), // 上传的图片
  124. FeedbackType: _this.feedbackType, // 反馈类型
  125. FeedbackDescribe: _this.describe, // 反馈的描述
  126. ClassId: classID, // 班级id
  127. DataFromType: _this.dataFromType, // 数据来源1:实验 2:评估
  128. FeedbackPath: window.location.href // 反馈的地址。就是学生反馈时所在的页面
  129. }
  130. console.log(feedbackData)
  131. this.$http.post('/education/api/TeacherFeedback/SaveFeedback', feedbackData).then(res => {
  132. this.$alert('反馈成功')
  133. _this.clearFeedbackData()
  134. // 调用父组件的刷新方法
  135. _this.$parent.getData()
  136. console.log(res)
  137. }).catch(e => {
  138. }
  139. )
  140. }
  141. }
  142. }
  143. </script>
  144. <style scoped="scoped" lang="scss">
  145. // 自定义的一根简单分割线
  146. .separateline {
  147. height: 1px;
  148. background: #eee;
  149. margin-left: -40px;
  150. margin-right: -40px;
  151. margin-top: 9px;
  152. }
  153. // 问题截图,传递图片的样式
  154. .form-content.panle {
  155. // padding: 20px;
  156. padding-bottom: 10px;
  157. // background-color: #f8f8f8;
  158. .img-boxs {
  159. display: flex;
  160. /* margin-right: 46px; */
  161. flex-wrap: wrap;
  162. .img-waper {
  163. margin-right: 10px;
  164. margin-bottom: 10px;
  165. position: relative;
  166. .remove-icon:hover {
  167. cursor: pointer;
  168. img {
  169. opacity: 0.6;
  170. }
  171. }
  172. .remove-icon {
  173. position: absolute;
  174. width: 14px;
  175. height: 14px;
  176. top: -8px;
  177. right: -5px;
  178. img {
  179. width: 100%;
  180. }
  181. }
  182. }
  183. }
  184. .add-btn:hover {
  185. cursor: pointer;
  186. opacity: 0.6;
  187. }
  188. .add-btn {
  189. width: 70px;
  190. height: 70px;
  191. border: solid 1px #DDDDDD;
  192. display: flex;
  193. align-items: center;
  194. flex-wrap: wrap;
  195. justify-content: space-around;
  196. .icon-waper {
  197. width: 18px;
  198. height: 21px;
  199. position: relative;
  200. .icon-x {
  201. width: 19px;
  202. height: 5px;
  203. background-color: #DDDDDD;
  204. position: absolute;
  205. top: 0;
  206. bottom: 0;
  207. margin: auto;
  208. }
  209. .icon-y {
  210. height: 21px;
  211. width: 5px;
  212. background-color: #DDDDDD;
  213. position: absolute;
  214. left: 0;
  215. right: 0;
  216. margin: auto;
  217. }
  218. }
  219. }
  220. }
  221. </style>
  222. <!-- 修改elementui里边对话框的默认样式
  223. 需要注意两点:
  224. 1:样式声明的时候不要加scoped,不然样式只在当前组件起作用,无法覆盖样式内容的样式
  225. 2:要修改默认弹窗里边的样式,加一个前缀,就可以做到只修改当前这个组件的了,不然可能会影响到其他地方的样式
  226. -->
  227. <style lang="scss">
  228. /* .dialogContent .el-dialog {
  229. background-color: #F6F8FC;
  230. }
  231. .dialogContent .el-dialog__header {
  232. padding: 20px 40px 10px 40px
  233. }
  234. .dialogContent .el-dialog__body {
  235. padding: 30px 40px;
  236. color: #606266;
  237. font-size: 14px;
  238. word-break: break-all;
  239. } */
  240. // 修改el-dialog里边的默认样式
  241. .dialogContent {
  242. .el-dialog {
  243. background-color: #F6F8FC;
  244. }
  245. .el-dialog__header {
  246. padding: 20px 40px 10px 40px;
  247. background-color: #f6f8fc !important;
  248. }
  249. .el-dialog__body {
  250. padding: 30px 40px;
  251. color: #606266;
  252. font-size: 14px;
  253. word-break: break-all;
  254. }
  255. .el-dialog__footer {
  256. padding: 0px 40px 30px 40px
  257. }
  258. // 修改默认按钮的padding也就是跳转按钮的宽度
  259. .el-button--small,
  260. .el-button--small.is-round {
  261. padding: 9px 16px;
  262. }
  263. // 修改默认按钮的圆角为直角
  264. .el-button--mini,
  265. .el-button--small {
  266. border-radius: 0px;
  267. }
  268. }
  269. </style>

图片上传的组件

  1. <!-- 问题反馈使用的弹窗 -->
  2. <template>
  3. <div>
  4. <!-- 图片上传start -->
  5. <div class="form-content panle">
  6. <div class="img-boxs">
  7. <div v-for="(item,i) in taskResoult.imgJson" :key="i+'img'" class="img-waper" @click="onPreviewImg(i)">
  8. <img
  9. :src="'/oss/api/ImageViewer/'+item.id+'.jpg?percent=0.6&quality=80&od=true'"
  10. width="79px"
  11. height="79px"
  12. >
  13. <div class="remove-icon" @click="rmImgs(i)">
  14. <img src="/asserts/img/error.png">
  15. </div>
  16. </div>
  17. <div v-if="taskResoult.imgJson.length<9" class="img-waper">
  18. <div class="add-btn" @click="addImgClick">
  19. <input
  20. ref="inputImgFile"
  21. type="file"
  22. style="display: none;"
  23. accept="image/*"
  24. @change="uploadimg"
  25. >
  26. <div class="icon-waper">
  27. <div class="icon-x" />
  28. <div class="icon-y" />
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <!-- 图片上传end -->
  35. <!-- 图片预览start -->
  36. <el-image-viewer
  37. v-if="showViewer"
  38. :z-index="20000"
  39. :initial-index="initialIndex"
  40. :append-to-body="true"
  41. :on-close="closeViewer"
  42. :mask-closable="false"
  43. :url-list="taskResoult.imgJson.map(a=>a.fileUrl)"
  44. />
  45. <!-- 图片预览end -->
  46. </div>
  47. </template>
  48. <script>
  49. import ElImageViewer from 'element-ui/packages/image/src/image-viewer'
  50. export default {
  51. // 组件名字
  52. name: 'UpLoadImg',
  53. components: {
  54. ElImageViewer
  55. },
  56. // 组件参数
  57. props: {
  58. index: {
  59. type: Number,
  60. default: 0
  61. }
  62. },
  63. data() {
  64. return {
  65. showViewer: false,
  66. initialIndex: 0,
  67. taskResoult: {
  68. 'uploadFileID': '',
  69. stuImgs: '',
  70. imgJson: [],
  71. 'uploadFileInfo': '',
  72. uploadFileInfoJson: {},
  73. 'remarks': null
  74. }
  75. }
  76. },
  77. mounted() {
  78. this.initPic()
  79. },
  80. // 组件方法
  81. methods: {
  82. initPic() {
  83. },
  84. // 点击添加图片,直接触发文件选择框的事件即可
  85. addImgClick() {
  86. this.$refs.inputImgFile.click()
  87. },
  88. // 打开图片预览
  89. onPreviewImg(i) {
  90. // 设置预览图片的索引
  91. this.initialIndex = i
  92. this.showViewer = true
  93. },
  94. // 获取当前上传的图片
  95. getImgs() {
  96. return this.taskResoult.imgJson
  97. },
  98. // 清空当前选择的图片
  99. clearImgs() {
  100. this.taskResoult.imgJson = []
  101. this.$forceUpdate()
  102. },
  103. // 关闭图片预览
  104. closeViewer() {
  105. this.showViewer = false
  106. },
  107. // 点击叉叉删除图片
  108. rmImgs(i) {
  109. this.taskResoult.imgJson.splice(i, 1)
  110. // console.log(self.taskResoult)
  111. this.$forceUpdate()
  112. },
  113. // 上传图片逻辑。文件选择框的change事件触发
  114. uploadimg(e) {
  115. // 日精进上传图片
  116. const imgFileExtensionArry = ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'psd', 'svg', 'tiff']
  117. const file = e.target.files[0]
  118. const fileExt = file.name.substr(file.name.lastIndexOf('.') + 1)
  119. if (imgFileExtensionArry.indexOf(fileExt.toLowerCase()) === -1) {
  120. this.$message.warning('仅允许提交图片文件!')
  121. return
  122. }
  123. const formData = new FormData()
  124. formData.append('bucketName', 'labroom')
  125. formData.append('filePath', 'feedback')
  126. formData.append('FileType', 1)
  127. formData.append('file', file)
  128. if (this.taskResoult.stuImgs && this.taskResoult.imgJson.length === 9) {
  129. this.$message.error('不允许超过9张图片')
  130. return
  131. }
  132. const self = this
  133. this.$http.post('/oss/api/SmartFiles/UpLoadFormFile', formData).then(res => {
  134. const imgInfo = {
  135. id: res.data.id,
  136. fileName: res.data.title,
  137. fileUrl: '/oss/api/ImageViewer/' + res.data.id + '.jpg'
  138. }
  139. self.taskResoult.imgJson.push(imgInfo)
  140. console.log(self.taskResoult)
  141. self.$forceUpdate()
  142. })
  143. }
  144. }
  145. }
  146. </script>
  147. <style scoped="scoped" lang="scss">
  148. // 问题截图,传递图片的样式
  149. .form-content.panle {
  150. // padding: 20px;
  151. padding-bottom: 10px;
  152. // background-color: #f8f8f8;
  153. .img-boxs {
  154. display: flex;
  155. /* margin-right: 46px; */
  156. flex-wrap: wrap;
  157. .img-waper {
  158. margin-right: 10px;
  159. margin-bottom: 10px;
  160. position: relative;
  161. .remove-icon:hover {
  162. cursor: pointer;
  163. img {
  164. opacity: 0.6;
  165. }
  166. }
  167. .remove-icon {
  168. position: absolute;
  169. width: 14px;
  170. height: 14px;
  171. top: -8px;
  172. right: -5px;
  173. img {
  174. width: 100%;
  175. }
  176. }
  177. }
  178. }
  179. .add-btn:hover {
  180. cursor: pointer;
  181. opacity: 0.6;
  182. }
  183. .add-btn {
  184. width: 79px;
  185. height: 79px;
  186. border: solid 1px #DDDDDD;
  187. display: flex;
  188. align-items: center;
  189. flex-wrap: wrap;
  190. justify-content: space-around;
  191. .icon-waper {
  192. width: 18px;
  193. height: 21px;
  194. position: relative;
  195. .icon-x {
  196. width: 19px;
  197. height: 5px;
  198. background-color: #DDDDDD;
  199. position: absolute;
  200. top: 0;
  201. bottom: 0;
  202. margin: auto;
  203. }
  204. .icon-y {
  205. height: 21px;
  206. width: 5px;
  207. background-color: #DDDDDD;
  208. position: absolute;
  209. left: 0;
  210. right: 0;
  211. margin: auto;
  212. }
  213. }
  214. }
  215. }
  216. </style>

欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739。有需要软件开发,或者学习软件技术的朋友可以和我联系~(Q:815170684)

评价

vue elementui常用表单验证

&lt;script&gt; exportdefault{ name:&quot;form&quot;, data(){ //ip地址校验 varIPValidator=(rule,value,callbac...

vue elementui隐藏表格列。vue element-ui表格添加自增序号列

vue elementui隐藏表格列v-if就搞定了,如果不是动态的显示与隐藏直接设置成false就行 &lt;el-table-column label=&quot;...

vue elementuivue3 element plus 文件上传的时候设置其他参数。后台.net接收传递的额外参数。图片上传

比如上传文件的时候额外传递两个select选择的值 前台前面上传文件的时候要提供默认参数很简单,el-upload绑定一个data即可...

vue elementui 图片预览。el-image-viewer图片查看器。修改图片预览的自带样式。点击哪一个就查看哪一个图片

先引入图片预览的组件 import ElImageViewer from &#39;element-ui/packages/image/src/image-viewer&#39; export defa...

vue elementui 常用表格条件查询类型解析弹窗显示详情图片显示图片预览

[TOC]第一版 页面&lt;template&gt; &lt;div class=&quot;app-container&quot;&gt; &lt;el-card&gt; &lt;!-...

vue elementui 弹窗el-dialog自定义弹窗样式单选按钮el-radio联动

效果如下: 代码如下: &lt;!-- 处理问题反馈使用的弹窗 --&gt; &lt;template&gt; &lt;div&gt; &lt;!-- 弹窗sta...

vue elementui分页条使用与.net后台sqlsugar等分页方法使用。常用分页模板

分页条&lt;div style=&quot;margin-top: 20px;margin-bottom: 20px;text-align: center;&quot;&gt; &lt;el-pagination ...

vue elementui table去掉滚动条

当table内容列过多时,可通过height属性设置table高度以固定table高度、固定表头,使table内容可以滚动。现在需求是右侧滚...

css弹性盒子flex布局

css弹性盒子由于版本不同浏览器问题造成了一些不同的写法display:flexbox;在google浏览器中如果使用下面的写法就不行displa...

可输入下拉文本框据输入动态加载数据 jquery-editable-select

用到一个jquery-editable-select的控件github地址:https://github.com/indrimuska/jquery-editable-select这个插件的原理是...

.net mvc分部页.net core分部页

.net分部页的三种方式第一种:@Html.Partial(&quot;_分部页&quot;)第二种:@{ Html.RenderPartial(&quot;分部页&quot;);}...

css中单位pxemrem和vh/vw的理解

&gt;px像素(Pixel)。相对长度单位。像素px是相对于显示器屏幕分辨率而言的。em是相对长度单位。相对于当前对象内文本的字...

让IIS支持webp格式图片让IIS支持vtt格式iis设置mime类型iis配置支持的类型

webp格式图片可以让图片体积变小。也让下载图片变得更加困难一点 在线制作webp工具 https://www.upyun.com/webp?utm_mediu...

网页上传文件断点续传的实现无视文件大小上传以及datatables基本用法

首先明白js是客户带执行代码,c#是服务器上执行代码。本地文件需要用到js处理,服务器端接受c#代码处理1.HTML页面,文件信...

如何使用图标像使用文字一样使用文本图标的方法

1.首先在Iconfont-阿里巴巴矢量图标库上面找到你需要的图标然后加入你的购物车然后选择图标;注意:每个类型的图标会大小不...