addzscount.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <view :style="'padding-bottom:' + bottom ">
  3. <view class='zhanline'></view>
  4. <uni-forms class='inform' ref="form" :rules="rules" :value="datainfo" >
  5. <uni-forms-item name="xmmc" style='margin-bottom: 0;'>
  6. <view class="flexc infolist">
  7. <view class="f16 fw c34 flex0 pr pl12">单位名称</view>
  8. <input placeholder="请输入单位名称" disabled="true" v-model="datainfo.deptName" class="f16 c34 flex1 txr"/>
  9. </view>
  10. </uni-forms-item>
  11. <uni-forms-item name="" style='margin-bottom: 0;'>
  12. <view class="flexc infolist">
  13. <view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>外出日期</view>
  14. <!-- fields="month" -->
  15. <picker mode="date" :value="datainfo.outsideTime" :end="currentdate" class="infolist_a" @change='bindDateChangea'>
  16. <view :class="datainfo.outsideTime?'':'f16 co80'">{{datainfo.outsideTime||"请选择外出日期"}}</view>
  17. </picker>
  18. </view>
  19. </uni-forms-item>
  20. <!-- <view class="info_tit">招商外出次数/天数</view> -->
  21. <uni-forms-item name="numberOutings" style='margin-bottom: 0;'>
  22. <view class="flexc infolist">
  23. <view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>外出天数</view>
  24. <input placeholder="请输入外出天数" type="number" v-model="datainfo.numberOutings" class="f16 c34 flex1 txr"/>
  25. </view>
  26. </uni-forms-item>
  27. <uni-forms-item name="outgoer" style='margin-bottom: 0;'>
  28. <view class="flexc infolist">
  29. <view class="f16 fw c34 flex0 pr pl12"><text class="cir">*</text>外出人员</view>
  30. <input placeholder="请输入外出人员" v-model="datainfo.outgoer" class="f16 c34 flex1 txr"/>
  31. </view>
  32. </uni-forms-item>
  33. <view class="border"></view>
  34. <uni-forms-item name="details" style='margin-bottom: 0;'>
  35. <view class="flexc infolist" style="align-items: flex-start;">
  36. <view class="f16 fw c34 flex0 pr pl12">情况说明</view>
  37. <uni-easyinput :inputBorder='false' type="textarea" v-model="datainfo.details" placeholder="请输入具体外出情况" placeholderStyle='text-align: right;font-size:32rpx;color:#808080'></uni-easyinput>
  38. </view>
  39. </uni-forms-item>
  40. <uni-forms-item name="zsyzFjList" style='margin-bottom: 0;'>
  41. <view class="flexc infolist">
  42. <view class="f16 fw c34 flex0 pr pl12">附件</view>
  43. <view class="infolist_a co28" ><lsj-upload
  44. ref="lsjUpload"
  45. childId="upload1"
  46. :width="width"
  47. :height="height"
  48. :option="option"
  49. :size="size"
  50. :formats="formats"
  51. :debug="debug"
  52. :instantly="instantly"
  53. @progress=""
  54. @uploadEnd="onuploadEnd" >
  55. <view class="btn" :style="{width: width,height: height}">选择附件</view>
  56. </lsj-upload></view>
  57. </view>
  58. </uni-forms-item>
  59. <view class=" cldelistbf" v-for="(ite,idx) in filelist" :key='idx'>
  60. <view class="flext f15 c6" @click="getDown(ite.path)">
  61. <view class="imgl"><image :src="wimg" ></image></view>
  62. <view>{{ite.fjName}}</view>
  63. </view>
  64. <!-- 删除 -->
  65. <view class="delimg flex0" @click.stop="getDelFj(idx)">
  66. <image :src="delimg"></image>
  67. </view>
  68. </view>
  69. <view class="infolist_b"><text>*</text>请上传大小不超过<text>100MB</text>格式为<text>doc/xls/ppt/txt/pdf/zip/rar/word</text>的文件</view>
  70. <view class="pfixedb flexc">
  71. <!-- 修改 -->
  72. <view v-if="checkPermi(['system:wczs:edit'])&&pagetype=='update'" class="infobtn flexcc cf f16 f500 btn2" @click="getSubmit">提交</view>
  73. <!-- 新增 -->
  74. <view v-if="checkPermi(['system:wczs:add'])&&pagetype=='add'" class="infobtn flexcc cf f16 f500 btn2" @click="getSubmit">提交</view>
  75. <view v-if="checkPermi(['system:wczs:remove'])&&pagetype=='update'" class="infobtn flexcc cf f16 f500 btn1" @click="getDelFn">删除</view>
  76. </view>
  77. </uni-forms>
  78. </view>
  79. </template>
  80. <script>
  81. import { getwczsaddFn,getwczsputFn,getwczsdetailFn,getwczsdelFn} from '@/api/work/count.js'
  82. import config from '@/config'
  83. const baseUrl = config.baseUrl
  84. import { getToken } from '@/utils/auth'
  85. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  86. export default {
  87. data() {
  88. return {
  89. //附件
  90. option: {
  91. // 上传服务器地址,需要替换为你的接口地址
  92. url: baseUrl+'/common/upload', // 该地址非真实路径,需替换为你项目自己的接口地址
  93. // 上传附件的key
  94. name: 'file',
  95. // 根据你接口需求自定义请求头,默认不要写content-type,让浏览器自适配
  96. header: {
  97. // 示例参数可删除
  98. 'Authorization': 'Bearer ' + getToken(),
  99. },
  100. // 根据你接口需求自定义body参数
  101. formData: {
  102. }
  103. },
  104. // 选择文件后是否立即自动上传,true=选择后立即上传
  105. instantly: true,
  106. // 必传宽高且宽高应与slot宽高保持一致
  107. width: '',
  108. height: '48rpx',
  109. // 限制允许上传的格式,空串=不限制,默认为空
  110. formats: 'doc,docx,xls,ppt,txt,pdf,zip,rar,word',
  111. // 文件上传大小限制
  112. size: 100,
  113. // 文件数量限制 默认10
  114. count: 5,
  115. // 文件回显列表
  116. files: new Map(),
  117. // 微信小程序Map对象for循环不显示,所以转成普通数组,不要问为什么,我也不知道
  118. wxFiles: [],
  119. // 是否打印日志
  120. debug: false,
  121. filelist:[],
  122. defaultPhoneHeight: '', //屏幕默认高度
  123. nowPhoneHeight: '', //屏幕现在的高度
  124. bottom:0,
  125. baseUrl:'',
  126. datainfo:{
  127. "deptName":"",//单位名称
  128. "year":"",//年
  129. "month":"",//月
  130. "outsideTime":"",//外出时间
  131. "numberOutings":"",//外出天数
  132. "outgoer":"",//外出人员
  133. "details":'',//情况说明
  134. zsyzFjList:[],//附件地址
  135. },
  136. rules: {
  137. outsideTime: {rules: [{required: true,errorMessage: '请选择外时间'}]},
  138. numberOutings: {rules: [{required: true,errorMessage: '请输入外出天数'},{pattern:/^[1-9]\d*$/,errorMessage: '请输入整数(天)'}]},
  139. outgoer: {rules: [{required: true,errorMessage: '请输入外出人员',}]},
  140. // zsyzFjList: {rules: [{required: true,errorMessage: '请上传附件'} ]},
  141. },
  142. wimg:require('@/static/images/index/wicon.png'),
  143. downimg:require('@/static/images/index/down.png'),
  144. delimg:require("@/static/images/mine/del.png"),
  145. pagetype:'add',
  146. strfrom:'tong',
  147. currentdate:'',
  148. }
  149. },
  150. onLoad(e) {
  151. this.baseUrl=baseUrl;
  152. this.pagetype=e.pagetype||'add';
  153. this.strfrom=e.strfrom||'tong';
  154. this.currentdate=this.getNowFormatDate();
  155. if(this.pagetype=='update'){
  156. // 获取详情 修改
  157. this.id=e.id
  158. this.getDataFn()
  159. }else{
  160. this.datainfo.outsideTime=this.getNowFormatDate();
  161. this.datainfo.deptName=this.$store.state.user.deptName;
  162. }
  163. // #ifdef APP
  164. uni.onKeyboardHeightChange(res=> { //监听键盘高度变化
  165. const res_keyboard = uni.getSystemInfoSync();
  166. let key_height = res.height - (res_keyboard.screenHeight - res_keyboard.windowHeight)
  167. // let key_height = res.height - (res_keyboard.screenHeight - res_keyboard.windowHeight + res_keyboard.safeAreaInsets.bottom)
  168. this.bottom = `${ key_height>0 ? key_height : 0}px`;
  169. })
  170. // #endif
  171. },
  172. onHide() {
  173. // #ifdef APP-PLUS
  174. uni.offKeyboardHeightChange(); // 取消监听键盘高度变化事件,避免内存消耗
  175. // #endif
  176. },
  177. onReady() {
  178. // this.$refs.form.setRules(this.rules)
  179. },
  180. methods: {
  181. checkPermi, checkRole,
  182. getNowFormatDate(){
  183. let date = new Date();
  184. let y = date.getFullYear();
  185. let m = date.getMonth() + 1;
  186. m = m < 10 ? "0" + m : m;
  187. let d = date.getDate();
  188. d = d < 10 ? "0" + d : d;
  189. const timeday = y + "-" + m+ "-" + d;
  190. this.datainfo.year=y;
  191. this.datainfo.month=m;
  192. return timeday;
  193. },
  194. // 详情
  195. getDataFn(){
  196. getwczsdetailFn(this.id).then(res=>{
  197. if(res.code==200){
  198. this.datainfo=res.data;
  199. if(res.data.zsyzFjList&&res.data.zsyzFjList.length){
  200. this.filelist=JSON.parse(JSON.stringify(res.data.zsyzFjList))
  201. }
  202. }else{
  203. this.$toast(res.msg)
  204. }
  205. })
  206. },
  207. bindDateChangea(e){//上报日期
  208. this.time=e.detail.value;
  209. var value=e.detail.value;
  210. var timestr=value.split('-');
  211. this.datainfo.year=timestr[0];
  212. this.datainfo.month=timestr[1];
  213. },
  214. getSubmit() {
  215. var that=this;
  216. this.datainfo.zsyzFjList=JSON.parse(JSON.stringify(this.filelist));
  217. this.$refs.form.validate().then(res => {
  218. var params=this.datainfo;
  219. // params.zsyzFjList=this.filelist
  220. if(this.pagetype=='add'){
  221. getwczsaddFn(params).then(res=>{
  222. if(res.code==200){
  223. this.$toast('上报信息成功')
  224. setTimeout(function() {
  225. if(that.strfrom=='tong'){
  226. uni.$emit('refreshdatatong');
  227. if(checkPermi(['system:qktj:list'])){
  228. that.$tab.redirectTo('/pages/work/count/cluelist')
  229. }else{
  230. uni.navigateBack({delta: 1});
  231. }
  232. }else{
  233. uni.$emit('refreshdata');
  234. uni.navigateBack({delta: 1});
  235. }
  236. },1500);
  237. }else{
  238. this.$toast(res.msg)
  239. }
  240. })
  241. }else{
  242. getwczsputFn(params).then(res=>{
  243. if(res.code==200){
  244. this.$toast('修改信息成功')
  245. setTimeout(function() {
  246. uni.$emit('refreshdata');
  247. uni.navigateBack({delta: 1});
  248. },1500);
  249. }else{
  250. this.$toast(res.msg)
  251. }
  252. })
  253. }
  254. })
  255. },
  256. getDelFn(){
  257. var that=this;
  258. uni.showModal({
  259. title: '确认删除',
  260. content: "是否确认删除",
  261. cancelText: '取消',
  262. confirmText: '确认',
  263. success: function(res) {
  264. if (res.confirm) {
  265. getwczsdelFn(that.id).then(res=>{
  266. if(res.code==200){
  267. that.$toast('删除信息成功')
  268. setTimeout(function() {
  269. uni.$emit('refreshdata');
  270. uni.navigateBack({delta: 1});
  271. },1500);
  272. }else{
  273. that.$toast(res.msg)
  274. }
  275. })
  276. } else if (res.cancel) {
  277. }
  278. }
  279. });
  280. },
  281. onuploadEnd(item) {
  282. var newobj={}
  283. var responseText=JSON.parse(item.responseText)
  284. newobj.fjName=responseText.originalFilename;
  285. newobj.path=responseText.fileName;
  286. this.filelist.push(newobj)
  287. this.datainfo.zsyzFjList=JSON.parse(JSON.stringify(this.filelist))
  288. },
  289. getDelFj(idx){
  290. var that=this;
  291. uni.showModal({
  292. title: '确认删除',
  293. content: "是否确认删除",
  294. cancelText: '取消',
  295. confirmText: '确认',
  296. success: function(res) {
  297. if (res.confirm) {
  298. that.filelist.splice(idx,1)
  299. that.datainfo.zsyzFjList=JSON.parse(JSON.stringify(that.filelist))
  300. } else if (res.cancel) {
  301. }
  302. }
  303. });
  304. },
  305. getDown(e){
  306. uni.showLoading({
  307. title: '加载中'
  308. });
  309. var url=baseUrl+e;
  310. uni.downloadFile({
  311. url: url,//文件的下载路径
  312. success(result) {
  313. uni.hideLoading()
  314. var filePath = result.tempFilePath;
  315. uni.openDocument({
  316. filePath: filePath,
  317. showMenu: true,
  318. success: function (res) {
  319. // console.log('打开文档成功');
  320. }
  321. });
  322. },
  323. fail(res) {uni.hideLoading()}
  324. })
  325. },
  326. }
  327. }
  328. </script>
  329. <style lang="scss" scoped>
  330. .inform{padding-top: 30rpx; padding-bottom: 160rpx;}
  331. .infolist{padding: 30rpx 32rpx 30rpx 24rpx;position: relative;
  332. .cir{position: absolute;font-size: 36rpx;font-weight: bold;color: #FE5706;left: 0rpx;}
  333. // .delimg{width: 30rpx;height:30rpx;margin-left: 8rpx;}
  334. }
  335. .delimg{width: 40rpx;height:40rpx;margin-left: 16rpx;display: flex;align-items: center;justify-content: center;
  336. image{width: 30rpx;height: 30rpx;}
  337. }
  338. .infobtn{width: 100%;height: 88rpx;background: #FA5F03;line-height: 88rpx;
  339. &.btn1{background-color: #1FB9F7;flex: 1;}
  340. &.btn2{background-color:#FF6400;flex: 1;}
  341. }
  342. .input_ye image{width: 34rpx;height: 18rpx;}
  343. .info_tit{font-size: 32rpx;color: #FE5706;padding: 50rpx 26rpx 20rpx;font-weight: bold;}
  344. .infolist_a{height: 44rpx;flex: 1;text-align: right;font-size: 32rpx;color: #343434;}
  345. .infolist_add{position: absolute;right: 0;top: -40rpx;font-size: 28rpx;color: #41C942;padding-right: 30rpx;
  346. image{width: 30rpx;height: 30rpx;margin-right: 20rpx;}
  347. }
  348. .fixedbtn{width:100%;height: 80rpx;background: #FF6400;
  349. border-radius: 10rpx;display: flex;align-items: center;justify-content: center;font-size: 32rpx;font-weight: bold;color: #FFFFFF;
  350. &.btn1{background-color: #20ACCF;margin-bottom: 36rpx;}
  351. }
  352. .fixedbox .infolist{padding: 30rpx 0;}
  353. .inform /deep/ .uni-forms-item__error{margin-top: -30rpx;margin-left: 24rpx;}
  354. .fixedbox /deep/ .uni-forms-item__error{margin-top: -30rpx;margin-left: 24rpx;}
  355. .inform .pl12{margin-right: 10rpx;}
  356. .fixedbox .pl12{margin-right: 10rpx;}
  357. .pholist{
  358. display: flex;align-items: center;max-width: 220rpx;overflow: hidden;
  359. image{
  360. width: 44rpx;height: 44rpx;margin-left: 10rpx;flex: 0 0 auto;
  361. }
  362. }
  363. .disabledbox{
  364. .infolist{background-color: #F5f5f5;}
  365. }
  366. </style>