newsaddvideo.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view class="check">
  3. <uni-forms ref="form" :model="datainfo">
  4. <view class="cbox">
  5. <view class="chmain">
  6. <uni-forms-item label="发布时间" name="publishTime">
  7. <picker mode="date" :disabled="isdisabled" @change='bindDateChangeb'>
  8. <view class="flexc">
  9. <view class="flex1 txr f13" :class="datainfo.publishTime?'co27':'coa'">{{datainfo.publishTime||"请选择发布时间"}}</view>
  10. <view class="rimg"><image :src="rimg"></image></view>
  11. </view>
  12. </picker>
  13. </uni-forms-item>
  14. <uni-forms-item label="是否启用" name="status">
  15. <view class="flexc" @click="getChangeFn">
  16. <view class="flex1"></view>
  17. <image :src="check" v-if="datainfo.status=='1'" class="checkimg"></image>
  18. <image :src="ncheck" v-else class="checkimg"></image>
  19. </view>
  20. </uni-forms-item>
  21. </view>
  22. </view>
  23. <view class="cbox">
  24. <view class="chmain">
  25. <uni-forms-item label-width='0' name="manualTitle">
  26. <uni-easyinput :disabled="isdisabled" type="textarea" autoHeight v-model="datainfo.manualTitle" :inputBorder='false' placeholder="输入标题" />
  27. </uni-forms-item>
  28. <view class="addbox">
  29. <lsj-upload ref="lsjUpload" childId="upload1" :width="width" :height="height" :option="option" :size="size" :formats="formats" :debug="debug" :instantly="instantly" bigType=''
  30. @progress="" @uploadEnd="onuploadEnd" >
  31. <!-- fileName="123" fileVal='dbxmhfhgb' bigType="c" -->
  32. <view class="flexdcc" :style="{width: width,height: height}">
  33. <image :src="video"></image>
  34. <view>添加视频</view>
  35. </view>
  36. </lsj-upload>
  37. </view>
  38. <view class="flexcw" v-if="datainfo.videoUrl">
  39. <view class="imgs">
  40. <video class="img" id="myVideo" :src="baseUrl+datainfo.videoUrl"
  41. @error="videoErrorCallback" controls></video>
  42. <image :src="del" class="del" @click.stop="getDelFn"></image>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </uni-forms>
  48. <view class="rfbtn" @click="getEditFn" v-if="isdisabled">修改</view>
  49. <view class="rfbtn" @click="getSubmit" v-else>发布</view>
  50. <loading></loading>
  51. </view>
  52. </template>
  53. <script>
  54. import config from '@/config'
  55. const baseUrl = config.baseUrl
  56. const Clientid = config.Clientid
  57. import { getToken } from '@/utils/auth'
  58. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  59. import {manualAdd,manualPut,manualDet} from "@/api/work/manage.js"
  60. import {uploadIdentify} from '@/utils/common.js'
  61. export default {
  62. components: {},
  63. data() {
  64. return {
  65. //附件
  66. option: {
  67. // 上传服务器地址,需要替换为你的接口地址
  68. url: baseUrl+'/common/upload', // 该地址非真实路径,需替换为你项目自己的接口地址
  69. // 上传附件的key
  70. name: 'file',
  71. // 根据你接口需求自定义请求头,默认不要写content-type,让浏览器自适配
  72. header: {
  73. // 示例参数可删除
  74. 'Authorization': 'Bearer ' + getToken(),
  75. 'Clientid': Clientid,
  76. },
  77. // 根据你接口需求自定义body参数
  78. formData: {
  79. }
  80. },
  81. // 选择文件后是否立即自动上传,true=选择后立即上传
  82. instantly: true,
  83. // 必传宽高且宽高应与slot宽高保持一致
  84. width: '642rpx',
  85. height: '190rpx',
  86. // 限制允许上传的格式,空串=不限制,默认为空
  87. formats: 'MP4',
  88. // 文件上传大小限制
  89. size: 100,
  90. // 文件数量限制 默认10
  91. count: 5,
  92. // 文件回显列表
  93. files: new Map(),
  94. // 微信小程序Map对象for循环不显示,所以转成普通数组,不要问为什么,我也不知道
  95. wxFiles: [],
  96. // 是否打印日志
  97. debug: false,
  98. filelist:[],
  99. rimg: require('@/people/static/people/rimg.png'),
  100. video: require('@/manage/static/community/video.png'),
  101. del: require('@/car/static/car/del.png'),
  102. baseUrl: config.baseUrl,
  103. checkflag:true,
  104. check: require('@/people/static/people/check.png'),
  105. ncheck: require('@/people/static/people/ncheck.png'),
  106. datainfo: {
  107. // "manualId":"员工培训手册ID",
  108. "manualTitle":"",//员工培训手册标题
  109. "manualType":"2",//员工培训手册类型(1:图片 2:视频)
  110. "manualContent":"",//员工培训手册内容
  111. "status":"1",//员工培训手册状态(1正常 2关闭)
  112. "publishTime":"",//发布时间
  113. "videoUrl":"",//视频地址URL
  114. // "coverImage":"封面图片",
  115. // "author":"作者",
  116. // "source":"来源",
  117. // "viewCount":"浏览次数",
  118. // "isTop":"是否置顶:Y(置顶)、N(不置顶)"
  119. },
  120. id:'',
  121. ptype:"add",
  122. isdisabled:false,
  123. editinfo:'',
  124. videofile:[],
  125. }
  126. },
  127. onLoad: function(e) {
  128. if(e.id){
  129. this.id=e.id;
  130. this.ptype='edit';
  131. // this.isdisabled=true;
  132. this.getDetailFn()
  133. }
  134. },
  135. methods: {
  136. checkPermi,
  137. checkRole,
  138. bindDateChangeb(e){
  139. var val=e.detail.value;
  140. this.datainfo.publishTime=val;
  141. },
  142. getEditFn(){
  143. this.isdisabled=false;
  144. },
  145. getDelFn(idx){
  146. var that=this;
  147. uni.showModal({
  148. title: '确认删除',
  149. content: "是否确认删除",
  150. cancelText: '取消',
  151. confirmText: '确认',
  152. success: function(res) {
  153. if (res.confirm) {
  154. that.datainfo.videoUrl='';
  155. } else if (res.cancel) {
  156. }
  157. }
  158. });
  159. },
  160. getChangeFn(){
  161. if(this.isdisabled){
  162. return
  163. }
  164. console.log(this.datainfo.status)
  165. if(this.datainfo.status=='1'){
  166. this.datainfo.status='2'
  167. }else{
  168. this.datainfo.status='1'
  169. }
  170. },
  171. // 上传
  172. onuploadEnd(item,fileVal,bigType) {
  173. var newobj={}
  174. var responseText=JSON.parse(item.responseText)
  175. if(responseText.code==200){
  176. this.datainfo.videoUrl=responseText.fileName
  177. // newobj.name=responseText.newFileName;
  178. // newobj.oldName=responseText.originalFilename;
  179. // newobj.url=responseText.fileName;
  180. // newobj.type=fileVal;
  181. // newobj.bigType=bigType;
  182. // newobj.suggestionId=this.suggestionId;
  183. // this.filelist.push(newobj)
  184. }else{
  185. this.$toast(responseText.msg)
  186. }
  187. },
  188. getDetailFn(){
  189. var that=this;
  190. manualDet(this.id).then(res=>{
  191. if(res.code==200){
  192. this.datainfo=res.data;
  193. }
  194. })
  195. },
  196. getSubmit(){
  197. var that=this;
  198. this.$refs.form.validate().then(res => {
  199. var params=JSON.parse(JSON.stringify(this.datainfo))
  200. if(!params.publishTime){
  201. this.$toast('请选择发布时间')
  202. return
  203. }
  204. if(!params.manualTitle){
  205. this.$toast('请输入标题')
  206. return
  207. }
  208. if(!params.videoUrl){
  209. this.$toast('请上传视频')
  210. return
  211. }
  212. if(this.ptype=='add'){
  213. manualAdd(params).then(res=>{
  214. if(res.code==200){
  215. this.$toast("新增成功")
  216. setTimeout(function(){
  217. uni.$emit("newsygList")
  218. uni.navigateBack({
  219. delta:1
  220. })
  221. },1500)
  222. }
  223. })
  224. }else{
  225. manualPut(params).then(res=>{
  226. if(res.code==200){
  227. this.$toast("修改成功")
  228. setTimeout(function(){
  229. uni.$emit("newsygList")
  230. uni.navigateBack({
  231. delta:1
  232. })
  233. },1500)
  234. }
  235. })
  236. }
  237. })
  238. },
  239. }
  240. }
  241. </script>
  242. <style>
  243. page{background: #F3F3F0;}
  244. </style>
  245. <style lang="scss" scoped>
  246. .check /deep/ .uni-forms-item{min-height: 106rpx;box-sizing: border-box;display: flex;align-items: center;margin-bottom: 0;border-bottom: 2rpx solid #E6E6E6;padding:10rpx 0;}
  247. .check .cbox /deep/ .uni-forms-item:last-child{border: none;}
  248. .check /deep/ .uni-forms-item__label{font-weight: bold;font-size: 26rpx;color: #222327;flex: 0 0 auto;width: auto !important;}
  249. .check /deep/ .uni-easyinput{flex: 1;text-align: left;font-size: 26rpx;color: #222327;}
  250. .check /deep/ .uni-easyinput__content-textarea{min-height: 40rpx;font-size: 26rpx;}
  251. .check /deep/ .uni-easyinput__placeholder-class{font-size: 26rpx;color: #AAAAAA;}
  252. .check /deep/ .uni-easyinput__content-input{padding-left: 0 !important;}
  253. .check /deep/ .uni-input-input{font-size: 26rpx;}
  254. .check /deep/ .uni-textarea-textarea{font-size: 26rpx;}
  255. .check /deep/ .is-disabled{color: #222327;background-color: #ffffff !important;}
  256. .check /deep/ .uni-data-checklist .checklist-group .checklist-box{margin:10rpx 8rpx 10rpx 16rpx;}
  257. .check /deep/ .uni-data-checklist{flex: 0 0 auto;}
  258. .check{min-height: 100vh;padding: 20rpx 18rpx 110rpx;box-sizing: border-box;}
  259. .cbox{background: #FFFFFF;border-radius: 20rpx;flex: 1;margin-bottom: 24rpx;
  260. .chmain{
  261. padding: 0 32rpx 10rpx;box-sizing: border-box;
  262. .rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
  263. image{width: 100%;height: 100%;}
  264. }
  265. .checkimg{width: 80rpx;height: 40rpx;margin-right: 8rpx;}
  266. }
  267. }
  268. .addbox{height: 190rpx;background: #FFFFFF;border-radius: 10rpx;border: 2rpx dashed #A7A7A7;margin: 48rpx 0 56rpx;
  269. image{width: 54rpx;height: 46rpx;margin-bottom: 16rpx;}
  270. view{font-weight: bold;font-size: 26rpx;color: #272727;}
  271. }
  272. .imgs{
  273. width: 310rpx;height: 186rpx;position: relative;margin: 0 10rpx 10rpx 0;
  274. .img{width: 100%;height: 100%;}
  275. .del{width: 24rpx;height: 24rpx;position: absolute;right: 0;top: 0;z-index: 2;}
  276. }
  277. </style>