add.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. <template>
  2. <view>
  3. <u-navbar :titleLong="fieldInfo.title">
  4. </u-navbar>
  5. <view class="businessMain" :style="'font-size:'+fieldInfo.fontsize+'rpx'">
  6. <view class="businessTitle" v-if="false">{{fieldInfo.title}}</view>
  7. <view v-for="(item,i) in fieldList" :key="i" class="oawork-item" :class="getClass(item)">
  8. <template v-if="item.type.indexOf('uview')>-1">
  9. <view v-if="item.type.indexOf('divider')>-1">
  10. <u-divider bg-color="#fff" border-color="#6d6d6d">{{item.text}}</u-divider>
  11. </view>
  12. </template>
  13. <template v-else>
  14. <view class="oawork-item1">
  15. <view class="oawork-item1_a">{{item.text}}<span v-if="item.isrequset" style="color:red">*</span>
  16. </view>
  17. <view class="oawork-item1_b">
  18. <template v-if="item.view">
  19. {{formData[item.key]?formData[item.key]:getViewItem(item)}}
  20. </template>
  21. <template v-else>
  22. <template v-if="item.type.indexOf('text')>-1">
  23. <u-input v-model="formData[item.key]" :placeholder="'请输入'+item.text"
  24. :placeholderStyle="placeholderStyle" class="oawork-line"
  25. :customStyle="{textAlign: 'right'}" />
  26. </template>
  27. <template v-if="item.type.indexOf('textnumber')>-1">
  28. <u-input v-model="formData[item.key]" type="number" :placeholder="'请输入'+item.text"
  29. :placeholderStyle="placeholderStyle" class="oawork-line"
  30. :customStyle="{textAlign: 'right'}" />
  31. </template>
  32. <template v-if="item.type.indexOf('radio')>-1">
  33. <u-radio-group v-model="formData[item.key]">
  34. <u-radio v-for="(item, index) in item.list?item.list:radioListDefault"
  35. :key="index" :name="item.value">
  36. {{item.name}}
  37. </u-radio>
  38. </u-radio-group>
  39. </template>
  40. <template v-if="item.type.indexOf('selecttime')>-1">
  41. <u-calendar max-date="2060-01-01" v-model="showCalendar" mode="date"
  42. @change="changeCalendar"></u-calendar>
  43. <view @click="showCalendar = true,keyCalendar=item">
  44. {{formData[item.key]?formData[item.key]:getViewItem(item)}}</view>
  45. </template>
  46. <template v-if="item.type.indexOf('selecttime2')>-1">
  47. <u-calendar max-date="2060-01-01" v-model="showCalendar" mode="range"
  48. @change="changeCalendar2"></u-calendar>
  49. <view @click="showCalendar = true,keyCalendar=item">
  50. {{formData[item.key]?formData[item.key]:createTime}}至{{formData[item.key2]?formData[item.key2]:createTime}}
  51. </view>
  52. </template>
  53. </template>
  54. </view>
  55. <view class="oawork-item1_c" v-if="item.type.indexOf('unit')>-1">
  56. {{item.unit}}
  57. </view>
  58. </view>
  59. <view class="oawork-item2">
  60. <template v-if="item.type.indexOf('textlong')>-1">
  61. <u-input v-model="formData[item.key]" :placeholder="'请输入'+item.text"
  62. :placeholderStyle="placeholderStyle" class="oawork-line" type="textarea" />
  63. </template>
  64. <template v-if="item.type.indexOf('upload')>-1">
  65. <view class="upload">
  66. <u-upload-file-all ref="uUpload" :action="action" :max-size="50 * 1024 * 1024"
  67. :file-max-size="50 * 1024 * 1024" :maxCount="9" :form-data="uploadData"
  68. :header="header" :file-list="fileList"></u-upload-file-all>
  69. </view>
  70. </template>
  71. <template v-if="item.type.indexOf('texteditor')>-1">
  72. <view class="container">
  73. <view class="page-body">
  74. <view class='wrapper'>
  75. <view class='toolbar' @tap="format" style="overflow-y: auto;">
  76. <view :class="formats.bold ? 'ql-active' : ''"
  77. class="iconfont icon-zitijiacu" data-name="bold"></view>
  78. <view :class="formats.italic ? 'ql-active' : ''"
  79. class="iconfont icon-zitixieti" data-name="italic"></view>
  80. <view :class="formats.underline ? 'ql-active' : ''"
  81. class="iconfont icon-zitixiahuaxian" data-name="underline"></view>
  82. <view :class="formats.strike ? 'ql-active' : ''"
  83. class="iconfont icon-zitishanchuxian" data-name="strike"></view>
  84. <view :class="formats.align === 'center' ? 'ql-active' : ''"
  85. class="iconfont icon-juzhongduiqi" data-name="align"
  86. data-value="center"></view>
  87. <view :class="formats.align === 'right' ? 'ql-active' : ''"
  88. class="iconfont icon-youduiqi" data-name="align" data-value="right">
  89. </view>
  90. <view :class="formats.align === 'justify' ? 'ql-active' : ''"
  91. class="iconfont icon-zuoyouduiqi" data-name="align"
  92. data-value="justify"></view>
  93. <view class="iconfont icon-clearedformat" @tap="removeFormat"></view>
  94. <view :class="formats.color === '#0000ff' ? 'ql-active' : ''"
  95. class="iconfont icon-text_color" data-name="color" data-value="#0000ff">
  96. </view>
  97. <view :class="formats.backgroundColor === '#00ff00' ? 'ql-active' : ''"
  98. class="iconfont icon-fontbgcolor" data-name="backgroundColor"
  99. data-value="#00ff00"></view>
  100. <view class="iconfont icon-date" @tap="insertDate"></view>
  101. <view class="iconfont icon--checklist" data-name="list" data-value="check">
  102. </view>
  103. <view :class="formats.list === 'ordered' ? 'ql-active' : ''"
  104. class="iconfont icon-youxupailie" data-name="list" data-value="ordered">
  105. </view>
  106. <view :class="formats.list === 'bullet' ? 'ql-active' : ''"
  107. class="iconfont icon-wuxupailie" data-name="list" data-value="bullet">
  108. </view>
  109. <view class="iconfont icon-undo" @tap="undo"></view>
  110. <view class="iconfont icon-redo" @tap="redo"></view>
  111. <view class="iconfont icon-outdent" data-name="indent" data-value="-1">
  112. </view>
  113. <view class="iconfont icon-indent" data-name="indent" data-value="+1">
  114. </view>
  115. <view class="iconfont icon-fengexian" @tap="insertDivider"></view>
  116. <view class="iconfont icon-charutupian" @tap="insertImage"></view>
  117. <view :class="formats.header === 1 ? 'ql-active' : ''"
  118. class="iconfont icon-format-header-1" data-name="header"
  119. :data-value="1"></view>
  120. <view :class="formats.script === 'sub' ? 'ql-active' : ''"
  121. class="iconfont icon-zitixiabiao" data-name="script" data-value="sub">
  122. </view>
  123. <view :class="formats.script === 'super' ? 'ql-active' : ''"
  124. class="iconfont icon-zitishangbiao" data-name="script"
  125. data-value="super"></view>
  126. <view class="iconfont icon-shanchu" @tap="clear"></view>
  127. <view :class="formats.direction === 'rtl' ? 'ql-active' : ''"
  128. class="iconfont icon-direction-rtl" data-name="direction"
  129. data-value="rtl"></view>
  130. </view>
  131. <view class="editor-wrapper">
  132. <editor id="editor" class="ql-container" placeholder="开始输入..." show-img-size
  133. show-img-toolbar show-img-resize @statuschange="onStatusChange"
  134. :read-only="readOnly" @ready="onEditorReady">
  135. </editor>
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. </template>
  141. </view>
  142. </template>
  143. </view>
  144. <view class="submitBtn">
  145. <u-button type="info" class="submitBtn30" @click="submit(0)">保存</u-button>
  146. <u-button type="primary" class="submitBtn60" @click="submit(1)">提交</u-button>
  147. </view>
  148. </view>
  149. <approve-view :activityList="activityList" :initStart="false"></approve-view>
  150. </view>
  151. </template>
  152. <script>
  153. import {
  154. dataJsGetInfo
  155. } from '../data.js'
  156. import * as API from '@/apis/pagejs/oa.js'
  157. import approveView from '@/components/ApproveView.vue'
  158. import {
  159. currentTimeStamp,
  160. parseUnixTime,
  161. } from '@/apis/utils'
  162. export default {
  163. components: {
  164. approveView
  165. },
  166. data() {
  167. return {
  168. //editor
  169. readOnly: false,
  170. formats: {},
  171. //editor
  172. oatype: "",
  173. showCalendar: false,
  174. keyCalendar: {},
  175. placeholderStyle: "font-size: 24rpx",
  176. radioListDefault: [{
  177. name: '是',
  178. value: '1'
  179. }, {
  180. name: '否',
  181. value: '0'
  182. }, ],
  183. fieldInfo: {},
  184. fieldList: [],
  185. activityList: [
  186. ],
  187. action: "",
  188. formData: {},
  189. personInfo: {},
  190. createTime: "",
  191. createTime2: "",
  192. uploadData: {},
  193. fileList: [],
  194. header: {
  195. },
  196. id: "",
  197. placeholder: '开始输入...'
  198. }
  199. },
  200. onLoad(op) {
  201. this.oatype = op.oatype
  202. if (op.id) {
  203. this.id = op.id
  204. }
  205. this.fieldInfo = dataJsGetInfo(op.oatype)
  206. this.fieldList = this.fieldInfo.list;
  207. this.getProcessDetails();
  208. },
  209. methods: {
  210. inspect(){
  211. // if (!this.form.verifyCode) {
  212. // uni.showToast({
  213. // title: "请输入验证码",
  214. // icon: "none"
  215. // })
  216. // return
  217. // }
  218. for(var i in this.fieldList){
  219. var item=this.fieldList[i]
  220. if(item.isrequset){
  221. //(item)
  222. var key=this.formData[item.key]
  223. if(!key){
  224. uni.showToast({
  225. title: "请输入"+item.text,
  226. icon: "none"
  227. })
  228. return false
  229. }
  230. }
  231. }
  232. return true
  233. },
  234. submit(draftStatus) {
  235. if(draftStatus){
  236. var c=this.inspect()
  237. if(!c){
  238. return
  239. }
  240. }
  241. uni.showLoading({
  242. title: "加载中",
  243. mask: true,
  244. })
  245. this.formData.draftStatus = draftStatus
  246. this.formData.formId = this.oatype
  247. if(this.$refs.uUpload){
  248. var list=this.$refs.uUpload[0].lists.filter(val => {
  249. return val.progress == 100;
  250. })
  251. if(list.length){
  252. var str =list.map(item=>{
  253. //(item)
  254. return JSON.stringify( {
  255. name:item.file?item.file.name:item.name,
  256. url:item.response?item.response.data.fileUrl:item.url
  257. })
  258. })
  259. this.formData.annexFile=JSON.stringify(str)
  260. }
  261. }
  262. API.application(this.fieldInfo.url, this.formData).then((res) => {
  263. uni.hideLoading();
  264. const eventChannel = this.getOpenerEventChannel();
  265. eventChannel.emit('refreshData');
  266. uni.showModal({
  267. title:"提示",
  268. showCancel:false,
  269. content:"操作成功!",
  270. success() {
  271. uni.navigateBack()
  272. }
  273. })
  274. ////(this.formData.maintenanceDescription,res.data.applyContent.maintenanceDescription)
  275. }).catch(error => {
  276. uni.showToast({
  277. title: error,
  278. icon: "none"
  279. })
  280. })
  281. },
  282. getProcessDetails() {
  283. uni.showLoading({
  284. title: "加载中",
  285. mask: true,
  286. })
  287. API.processDetails({
  288. formId: this.oatype,
  289. id: this.id
  290. }).then((res) => {
  291. uni.hideLoading();
  292. this.activityList = res.data.activityList
  293. var applyContent = res.data.applyContent
  294. this.init()
  295. if(applyContent){
  296. this.formData.id=applyContent.id
  297. for (var i in this.fieldList) {
  298. var obj = this.fieldList[i];
  299. //(this.formData[obj.key], applyContent[obj.key])
  300. var data=applyContent[obj.key];
  301. if(data==null){
  302. continue
  303. }
  304. if (obj.type.indexOf("upload") > -1) {
  305. if(data){
  306. var sz=JSON.parse(data).map(str=>{
  307. var item=JSON.parse(str)
  308. return {
  309. url:item.url,name:item.name,view:1
  310. }
  311. })
  312. this.fileList=sz//data.split(",").map(item=>{return {url:item,item.name=,view:1}})
  313. }
  314. }
  315. this.formData[obj.key] = applyContent[obj.key]
  316. }
  317. }
  318. //(this.formData)
  319. ////(this.formData.maintenanceDescription,res.data.applyContent.maintenanceDescription)
  320. }).catch(error => {
  321. uni.showToast({
  322. title: error,
  323. icon: "none"
  324. })
  325. })
  326. },
  327. saveStorage() {
  328. },
  329. gotoSelectPerson(item) {
  330. this.saveStorage();
  331. uni.navigateTo({
  332. url: "/pages/oawork/business/select"
  333. })
  334. },
  335. changeCalendar(e) {
  336. this.formData[this.keyCalendar.key] = e.result;
  337. },
  338. changeCalendar2(e) {
  339. this.formData[this.keyCalendar.key] = e.startDate;
  340. this.formData[this.keyCalendar.key2] = e.endDate;
  341. },
  342. init() {
  343. this.personInfo = this.carhelp.getPersonInfo()
  344. this.createTime = parseUnixTime(currentTimeStamp(), '{y}-{m}-{d}');
  345. this.createTime2 = parseUnixTime(currentTimeStamp());
  346. for (var i in this.fieldList) {
  347. var obj = this.fieldList[i];
  348. this.formData[obj.key] = ""
  349. }
  350. this.action = process.car.BASE_URL + "uploadPicture"
  351. this.uploadData.subFolder = "oawork11" + this.oatype;
  352. //接口应该免登陆
  353. var token = this.carhelp.getToken()
  354. this.header = {
  355. 'Authorization': token
  356. }
  357. },
  358. getViewItem(item) {
  359. //(item)
  360. if (item.sql) {
  361. var obj = this;
  362. for (var i in item.sql) {
  363. var k = item.sql[i];
  364. obj = obj[k]
  365. this.formData[item.key]=obj
  366. }
  367. return obj;
  368. }
  369. },
  370. getClass(item) {
  371. if (item) {
  372. var list = item.type.map(it => {
  373. return 'oawork-' + it
  374. })
  375. return list.join(' ')
  376. }
  377. },
  378. //editor
  379. readOnlyChange() {
  380. this.readOnly = !this.readOnly
  381. },
  382. onEditorReady() {
  383. // #ifdef MP-BAIDU
  384. this.editorCtx = requireDynamicLib('editorLib').createEditorContext('editor');
  385. // #endif
  386. // #ifdef APP-PLUS || MP-WEIXIN || H5
  387. uni.createSelectorQuery().select('#editor').context((res) => {
  388. this.editorCtx = res.context
  389. }).exec()
  390. // #endif
  391. },
  392. undo() {
  393. this.editorCtx.undo()
  394. },
  395. redo() {
  396. this.editorCtx.redo()
  397. },
  398. format(e) {
  399. let {
  400. name,
  401. value
  402. } = e.target.dataset
  403. if (!name) return
  404. // //('format', name, value)
  405. this.editorCtx.format(name, value)
  406. },
  407. onStatusChange(e) {
  408. const formats = e.detail
  409. this.formats = formats
  410. },
  411. insertDivider() {
  412. this.editorCtx.insertDivider({
  413. success: function() {
  414. //('insert divider success')
  415. }
  416. })
  417. },
  418. clear() {
  419. uni.showModal({
  420. title: '清空编辑器',
  421. content: '确定清空编辑器全部内容?',
  422. success: res => {
  423. if (res.confirm) {
  424. this.editorCtx.clear({
  425. success: function(res) {
  426. //("clear success")
  427. }
  428. })
  429. }
  430. }
  431. })
  432. },
  433. removeFormat() {
  434. this.editorCtx.removeFormat()
  435. },
  436. insertDate() {
  437. const date = new Date()
  438. const formatDate = `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`
  439. this.editorCtx.insertText({
  440. text: formatDate
  441. })
  442. },
  443. insertImage() {
  444. uni.chooseImage({
  445. count: 1,
  446. success: (res) => {
  447. this.editorCtx.insertImage({
  448. src: res.tempFilePaths[0],
  449. alt: '图像',
  450. success: function() {
  451. //('insert image success')
  452. }
  453. })
  454. }
  455. })
  456. },
  457. //editor
  458. }
  459. }
  460. </script>
  461. <style scoped lang="scss">
  462. .oawork-line {
  463. border-bottom: 1px solid #c8c8c8;
  464. }
  465. .oawork-paddingTop {
  466. padding-top: 40rpx;
  467. }
  468. .approveMain_text {
  469. font-weight: bold;
  470. color: rgba(51, 51, 51, 1);
  471. font-size: 32rpx;
  472. padding-bottom: 20rpx;
  473. padding-left: 32rpx;
  474. border-bottom: 1px solid #C8C8C8;
  475. margin-bottom: 16rpx;
  476. // padding-top: 32rpx;
  477. }
  478. .businessMain {
  479. /deep/.uni-input-input {
  480. font-size: 24rpx;
  481. }
  482. font-size: 32rpx;
  483. background: #fff;
  484. padding-top: 10rpx;
  485. padding-bottom: 50rpx;
  486. margin-bottom: 40rpx;
  487. display: flex;
  488. flex-wrap: wrap;
  489. .oawork-item {
  490. padding: 4rpx 16rpx 4rpx 16rpx;
  491. width: 100%;
  492. .oawork-item1 {
  493. display: flex;
  494. align-items: center;
  495. .oawork-item1_a {
  496. min-width: 160rpx;
  497. font-weight: bold;
  498. }
  499. .oawork-item1_b {
  500. color: #777777;
  501. width: 100%;
  502. text-align: right;
  503. }
  504. .oawork-item1_c {
  505. padding-left: 16rpx;
  506. }
  507. }
  508. }
  509. .oawork-selecttime,
  510. .oawork-selecttime2 {
  511. margin: 10rpx 0;
  512. display: flex;
  513. .oawork-item1 {
  514. width: 100%;
  515. }
  516. .oawork-item1_b {
  517. display: flex;
  518. align-items: center;
  519. justify-content: flex-end;
  520. height: 100%;
  521. border-bottom: 1px solid #c8c8c8;
  522. }
  523. }
  524. .oawork-itemrow {
  525. .oawork-item1_a {
  526. font-weight: 400 !important;
  527. width: 200%;
  528. }
  529. }
  530. .oawork-textlong {
  531. .oawork-item1_a {
  532. width: 100%;
  533. }
  534. }
  535. .oawork-title {
  536. padding: 20rpx 0px 4rpx 20rpx;
  537. .oawork-item1_a {
  538. width: 100%;
  539. font-size: 32rpx;
  540. }
  541. }
  542. .width200 {
  543. // padding:20rpx 0px 4rpx 20rpx;
  544. .oawork-item1_a {}
  545. }
  546. /deep/.oawork-width49 {
  547. padding: 4rpx 0px 4rpx 20rpx;
  548. width: 49%;
  549. .oawork-item1_a {
  550. min-width: 140rpx !important;
  551. }
  552. }
  553. }
  554. .approveMain {
  555. background: #fff;
  556. padding-bottom: 180rpx;
  557. padding-top: 20rpx;
  558. .approveItem_main {
  559. display: flex;
  560. justify-content: space-between;
  561. margin-bottom: 30rpx;
  562. margin-right: 32rpx;
  563. .approveItem_a1 {
  564. .approveItem_a1_text1 {
  565. color: rgba(16, 16, 16, 1);
  566. font-size: 32rpx;
  567. }
  568. .approveItem_a1_text2 {
  569. margin-bottom: 16rpx;
  570. color: rgba(119, 119, 119, 1);
  571. font-size: 24rpx;
  572. }
  573. .approveItem_a1_text3 {
  574. color: rgba(51, 51, 51, 1);
  575. font-size: 24rpx;
  576. display: flex;
  577. flex-direction: row;
  578. flex-wrap: wrap;
  579. .approveItem_a1_text3Img {
  580. margin-right: 40rpx;
  581. margin-top: 10rpx;
  582. /deep/.u-badge {
  583. position: relative !important;
  584. top: -40rpx !important;
  585. right: 10rpx !important;
  586. }
  587. }
  588. }
  589. }
  590. .approveItem_a2 {
  591. .a2_span {
  592. border-radius: 4px;
  593. text-align: center;
  594. border: 1px solid rgba(227, 227, 227, 1);
  595. width: 72rpx;
  596. height: 72rpx;
  597. line-height: 60rpx;
  598. font-size: 48rpx;
  599. color: #9F9F9F;
  600. }
  601. .a2_span_2 {
  602. position: relative;
  603. top: -84rpx;
  604. left: 60rpx;
  605. color: red;
  606. }
  607. }
  608. }
  609. }
  610. .u-node {
  611. width: 18rpx;
  612. height: 18rpx;
  613. border-radius: 100rpx !important;
  614. display: flex;
  615. justify-content: center;
  616. align-items: center;
  617. background: #d0d0d0;
  618. }
  619. .submitBtn {
  620. bottom: 0;
  621. position: fixed;
  622. width: 100%;
  623. padding: 20rpx 40rpx;
  624. background-color: #fff;
  625. border-top: 3px solid #f3f4f4;
  626. z-index: 99;
  627. display: flex;
  628. .submitBtn30 {
  629. width: 30%;
  630. }
  631. .submitBtn60 {
  632. width: 60%;
  633. }
  634. }
  635. @import "../data/editor-icon.css";
  636. </style>