view.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <view>
  3. <u-navbar :titleLong="fieldInfo.title">
  4. </u-navbar>
  5. <approve-info v-if="viewApproveBl"
  6. :fieldInfo="fieldInfo" :formData="formData" :fileList="fileList" ></approve-info>
  7. <view class="submitBtn" v-if="0">
  8. <u-button type="info" class="submitBtn30">保存</u-button>
  9. <u-button type="primary" class="submitBtn60" >提交</u-button>
  10. </view>
  11. <approve-view :activityList="activityList"></approve-view>
  12. </view>
  13. </template>
  14. <script>
  15. import {
  16. dataJsGetInfo
  17. } from '../data.js'
  18. import * as API from '@/apis/pagejs/oa.js'
  19. import approveView from '@/components/ApproveView.vue'
  20. import approveInfo from '@/components/ApproveInfo.vue'
  21. import {
  22. currentTimeStamp,
  23. parseUnixTime,
  24. } from '@/apis/utils'
  25. export default {
  26. components: {
  27. approveView,approveInfo
  28. },
  29. data() {
  30. return {
  31. //editor
  32. readOnly: false,
  33. formats: {},
  34. //editor
  35. oatype: "",
  36. showCalendar: false,
  37. keyCalendar: {},
  38. placeholderStyle: "font-size: 24rpx",
  39. radioListDefault: [{
  40. name: '是',
  41. value: '1'
  42. }, {
  43. name: '否',
  44. value: '0'
  45. }, ],
  46. fieldInfo: {},
  47. fieldList: [],
  48. formData: {},
  49. activityList: [
  50. ],
  51. action: "",
  52. personInfo: {},
  53. createTime: "",
  54. createTime2: "",
  55. uploadData: {},
  56. fileList: [],
  57. header: {
  58. },
  59. viewApproveBl:false,
  60. id: "",
  61. placeholder: '开始输入...'
  62. }
  63. },
  64. onLoad(op) {
  65. this.oatype = op.oatype
  66. if (op.id) {
  67. this.id = op.id
  68. }
  69. this.fieldInfo = dataJsGetInfo(op.oatype)
  70. //console.log(this.fieldInfo)
  71. this.fieldList = this.fieldInfo.list;
  72. this.getProcessDetails();
  73. },
  74. methods: {
  75. submit(draftStatus) {
  76. },
  77. getProcessDetails() {
  78. uni.showLoading({
  79. title: "加载中",
  80. mask: true,
  81. })
  82. API.processDetails({
  83. formId: this.oatype,
  84. id: this.id
  85. }).then((res) => {
  86. uni.hideLoading();
  87. this.activityList = res.data.activityList
  88. var applyContent = res.data.applyContent
  89. this.init()
  90. if(applyContent){
  91. this.formData.id=applyContent.id
  92. for (var i in this.fieldList) {
  93. var obj = this.fieldList[i];
  94. //(this.formData[obj.key], applyContent[obj.key])
  95. var data=applyContent[obj.key];
  96. if(data==null){
  97. continue
  98. }
  99. if (obj.type.indexOf("upload") > -1) {
  100. if(data){
  101. var sz=JSON.parse(data).map(str=>{
  102. var item=JSON.parse(str)
  103. return {
  104. url:item.url,name:item.name,view:1
  105. }
  106. })
  107. this.fileList=sz//data.split(",").map(item=>{return {url:item,item.name=,view:1}})
  108. }
  109. }
  110. this.formData[obj.key] = applyContent[obj.key]
  111. }
  112. }
  113. this.viewApproveBl=true
  114. console.log(this.formData)
  115. }).catch(error => {
  116. uni.showToast({
  117. title: error,
  118. icon: "none"
  119. })
  120. })
  121. },
  122. saveStorage() {
  123. },
  124. gotoSelectPerson(item) {
  125. this.saveStorage();
  126. uni.navigateTo({
  127. url: "/pages/oawork/business/select"
  128. })
  129. },
  130. changeCalendar(e) {
  131. this.formData[this.keyCalendar.key] = e.result;
  132. },
  133. changeCalendar2(e) {
  134. this.formData[this.keyCalendar.key] = e.startDate;
  135. this.formData[this.keyCalendar.key2] = e.endDate;
  136. },
  137. init() {
  138. this.personInfo = this.carhelp.getPersonInfo()
  139. this.createTime = parseUnixTime(currentTimeStamp(), '{y}-{m}-{d}');
  140. this.createTime2 = parseUnixTime(currentTimeStamp());
  141. for (var i in this.fieldList) {
  142. var obj = this.fieldList[i];
  143. this.formData[obj.key] = ""
  144. }
  145. this.action = process.car.BASE_URL + "uploadPicture"
  146. this.uploadData.subFolder = "oawork11" + this.oatype;
  147. //接口应该免登陆
  148. var token = this.carhelp.getToken()
  149. this.header = {
  150. 'Authorization': token
  151. }
  152. },
  153. getViewItem(item) {
  154. console.log(item)
  155. if (item.sql) {
  156. var obj = this;
  157. for (var i in item.sql) {
  158. var k = item.sql[i];
  159. obj = obj[k]
  160. }
  161. return obj;
  162. }
  163. },
  164. getClass(item) {
  165. if (item) {
  166. var list = item.type.map(it => {
  167. return 'oawork-' + it
  168. })
  169. return list.join(' ')
  170. }
  171. },
  172. //editor
  173. readOnlyChange() {
  174. this.readOnly = !this.readOnly
  175. },
  176. onEditorReady() {
  177. // #ifdef MP-BAIDU
  178. this.editorCtx = requireDynamicLib('editorLib').createEditorContext('editor');
  179. // #endif
  180. // #ifdef APP-PLUS || MP-WEIXIN || H5
  181. uni.createSelectorQuery().select('#editor').context((res) => {
  182. this.editorCtx = res.context
  183. }).exec()
  184. // #endif
  185. },
  186. undo() {
  187. this.editorCtx.undo()
  188. },
  189. redo() {
  190. this.editorCtx.redo()
  191. },
  192. format(e) {
  193. let {
  194. name,
  195. value
  196. } = e.target.dataset
  197. if (!name) return
  198. // console.log('format', name, value)
  199. this.editorCtx.format(name, value)
  200. },
  201. onStatusChange(e) {
  202. const formats = e.detail
  203. this.formats = formats
  204. },
  205. insertDivider() {
  206. this.editorCtx.insertDivider({
  207. success: function() {
  208. console.log('insert divider success')
  209. }
  210. })
  211. },
  212. clear() {
  213. uni.showModal({
  214. title: '清空编辑器',
  215. content: '确定清空编辑器全部内容?',
  216. success: res => {
  217. if (res.confirm) {
  218. this.editorCtx.clear({
  219. success: function(res) {
  220. console.log("clear success")
  221. }
  222. })
  223. }
  224. }
  225. })
  226. },
  227. removeFormat() {
  228. this.editorCtx.removeFormat()
  229. },
  230. insertDate() {
  231. const date = new Date()
  232. const formatDate = `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`
  233. this.editorCtx.insertText({
  234. text: formatDate
  235. })
  236. },
  237. insertImage() {
  238. uni.chooseImage({
  239. count: 1,
  240. success: (res) => {
  241. this.editorCtx.insertImage({
  242. src: res.tempFilePaths[0],
  243. alt: '图像',
  244. success: function() {
  245. console.log('insert image success')
  246. }
  247. })
  248. }
  249. })
  250. },
  251. //editor
  252. }
  253. }
  254. </script>
  255. <style scoped lang="scss">
  256. .oawork-line {
  257. border-bottom: 1px solid #c8c8c8;
  258. }
  259. .oawork-paddingTop {
  260. padding-top: 40rpx;
  261. }
  262. .businessMain {
  263. /deep/.uni-input-input {
  264. font-size: 24rpx;
  265. }
  266. font-size: 32rpx;
  267. background: #fff;
  268. padding-top: 10rpx;
  269. padding-bottom: 50rpx;
  270. margin-bottom: 40rpx;
  271. display: flex;
  272. flex-wrap: wrap;
  273. .oawork-item {
  274. padding: 4rpx 16rpx 4rpx 16rpx;
  275. width: 100%;
  276. .oawork-item1 {
  277. display: flex;
  278. align-items: center;
  279. .oawork-item1_a {
  280. min-width: 160rpx;
  281. font-weight: bold;
  282. }
  283. .oawork-item1_b {
  284. color: #777777;
  285. width: 100%;
  286. text-align: right;
  287. }
  288. .oawork-item1_c {
  289. padding-left: 16rpx;
  290. }
  291. }
  292. }
  293. .oawork-selecttime,
  294. .oawork-selecttime2 {
  295. margin: 10rpx 0;
  296. display: flex;
  297. .oawork-item1 {
  298. width: 100%;
  299. }
  300. .oawork-item1_b {
  301. display: flex;
  302. align-items: center;
  303. justify-content: flex-end;
  304. height: 100%;
  305. border-bottom: 1px solid #c8c8c8;
  306. }
  307. }
  308. .oawork-itemrow {
  309. .oawork-item1_a {
  310. font-weight: 400 !important;
  311. width: 200%;
  312. }
  313. }
  314. .oawork-textlong {
  315. .oawork-item1_a {
  316. width: 100%;
  317. }
  318. }
  319. .oawork-title {
  320. padding: 20rpx 0px 4rpx 20rpx;
  321. .oawork-item1_a {
  322. width: 100%;
  323. font-size: 32rpx;
  324. }
  325. }
  326. .width200 {
  327. // padding:20rpx 0px 4rpx 20rpx;
  328. .oawork-item1_a {}
  329. }
  330. /deep/.oawork-width49 {
  331. padding: 4rpx 0px 4rpx 20rpx;
  332. width: 49%;
  333. .oawork-item1_a {
  334. min-width: 140rpx !important;
  335. }
  336. }
  337. }
  338. .submitBtn {
  339. bottom: 0;
  340. position: fixed;
  341. width: 100%;
  342. padding: 20rpx 40rpx;
  343. background-color: #fff;
  344. border-top: 3px solid #f3f4f4;
  345. z-index: 9999;
  346. display: flex;
  347. .submitBtn30 {
  348. width: 30%;
  349. }
  350. .submitBtn60 {
  351. width: 60%;
  352. }
  353. }
  354. @import "../data/editor-icon.css";
  355. </style>