addkscount.vue 13 KB

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