You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

650 lines
19 KiB

  1. <template>
  2. <view class="page">
  3. <view>
  4. <view class="cu-bar bg-white cu-title solid-bottom">
  5. <view class="action" style="vertical-align: middle;">
  6. <text class="margin-right-xs text-blue cuIcon-title">
  7. <span></span>
  8. </text>
  9. <text class="text-xl">
  10. <span>经费开支申报单</span>
  11. </text>
  12. </view>
  13. </view>
  14. </view>
  15. <view v-if="ready">
  16. <l-input @input="setValue('FundsApply.EnCode', $event)" :value="getValue('FundsApply.EnCode')"
  17. title="申报单号" /> <!-- v-if="!edit" :disabled="!edit" -->
  18. <l-select @input="setValue('FundsApply.ApplyDept', $event)" :value="getValue('FundsApply.ApplyDept')"
  19. :range="dataSource.FundsApply.ApplyDept" title="申报部门" disabled />
  20. <!-- :disabled="!edit" v-if="!edit" -->
  21. <l-datetime-picker @input="setValue('FundsApply.ApplyTime', $event)"
  22. :value="getValue('FundsApply.ApplyTime')" title="填报时间" disabled /> <!-- required :disabled="!edit" -->
  23. <l-select @input="setValue('FundsApply.ApplyUser', $event)" :value="getValue('FundsApply.ApplyUser')"
  24. :range="dataSource.FundsApply.ApplyUser" title="填报人" disabled /> <!-- v-if="!edit" -->
  25. <l-select @input="setValue('FundsApply.IsFixedAssets', $event)"
  26. :value="getValue('FundsApply.IsFixedAssets')" :range="dataSource.FundsApply.IsFixedAssets"
  27. title="是否固定资产" :disabled="!edit" /> <!-- v-if="!edit" -->
  28. <l-textarea @input="setValue('FundsApply.Remark', $event)" :value="getValue('FundsApply.Remark')" title="备注"
  29. :readonly="!edit" /> <!-- v-if="!edit" :readonly="!edit" -->
  30. <!-- <l-input @input="setValue('FundsApply.Remark', $event)" :value="getValue('FundsApply.Remark')"
  31. title="申请人" :disabled="!edit" /> -->
  32. <l-input @input="Statusitem(setValue('FundsApply.Status', $event)) "
  33. :value="Statusitem(getValue('FundsApply.Status'))" title="审批状态" disabled v-if="!edit" />
  34. <!-- :disabled="!edit" -->
  35. <!-- 附件上传 -->
  36. <l-input
  37. @input="setValue('FundsApply.Path', $event)"
  38. :value="getValue('FundsApply.Path')"
  39. disabled="disabled"
  40. v-show="false"
  41. title="附件值"
  42. />
  43. <uploadFile :number="5" :folderId="folderId" :value="fileList" :readonly="!edit" :title="fileTitle" :required="false"></uploadFile>
  44. </view>
  45. <view class="welT" style="padding-top: 10px;">
  46. 明细操作
  47. <text v-if="edit" class="text-xxl cuIcon cuIcon-add" @click="add('FundsApplyDetails')"></text>
  48. </view>
  49. <view class="welBox" id="StuInfoFreshEmergePeople" v-show="FundsApplyDetail.length != 0">
  50. <view class="welCon" v-for="(item, i) in FundsApplyDetail" :key='i'>
  51. <l-input v-model="item.ProjectContent" title="项目明细" placeholder="请填写" right :disabled="!edit" />
  52. <l-input v-model="item.Number" type="number" @blur="SumAmountChange(item,'Number')" title="数量" :disabled="!edit" placeholder="请填写" right />
  53. <l-label title="单位">
  54. <picker
  55. @change="changeitem($event,item)"
  56. :range="dataSource.FundsApply.Unit"
  57. :disabled="!edit"
  58. range-key="text"
  59. >
  60. <view class="picker">{{ item.Unit ? mapitem(item.Unit) : '请选择单位' }}</view>
  61. </picker>
  62. </l-label>
  63. <l-input v-model="item.Price" type="digit" @blur="blurChange(item)" title="单价(元)" :disabled="!edit" placeholder="请填写" right />
  64. <l-input v-model="item.Amount" title="金额(元)" disabled placeholder="请填写" right />
  65. <!-- <l-select @input="setValue('item.Unit', $event)" :value="getValue('item.Unit')" :range="dataSource.FundsApply.Unit" title="单位" :disabled="!edit" /> -->
  66. <view v-if="edit||create" class="welDel" @click="del('FundsApplyDetails', i)"><text
  67. class="text-xxl cuIcon cuIcon-move"></text></view>
  68. <view v-if="edit||create" class="welAdd" @click="add('FundsApplyDetails')">
  69. <text class="text-xxl cuIcon cuIcon-add"></text>
  70. </view>
  71. </view>
  72. </view>
  73. <view v-if="ready">
  74. <l-input @input="setValue('FundsApply.SumAmount', $event)" :value="getValue('FundsApply.SumAmount')"
  75. title="合计" disabled="" /> <!-- v-if="!edit" :disabled="!edit" -->
  76. <l-input @input="setValue('FundsApply.UpperAmount', $event)" :value="getValue('FundsApply.UpperAmount')"
  77. title="人民币(大写)" disabled /> <!-- v-if="!edit" :disabled="!edit" -->
  78. </view>
  79. <view v-if="ready&&edit" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
  80. <l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block>
  81. 保存
  82. </l-button>
  83. <l-button v-if="!edit && mode !== 'create'" @click="action('edit')" size="lg" line="orange"
  84. class="block margin-top" block>
  85. 编辑本页
  86. </l-button>
  87. <l-button v-if="edit && mode !== 'create'" @click="action('reset')" size="lg" line="red"
  88. class="block margin-top" block>
  89. 取消编辑
  90. </l-button>
  91. <l-button v-if="!edit && mode !== 'create'" @click="action('delete')" size="lg" line="red"
  92. class="block margin-top" block>
  93. 删除
  94. </l-button>
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. /*
  100. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  101. * Copyright (c) 2013-2021 上海力软信息技术有限公司
  102. * 创建人:超级管理员
  103. * 日 期:2021-02-21 10:07
  104. * 描 述:会议管理
  105. */
  106. /**
  107. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  108. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  109. * { "path": "pages/PersonnelManagement/FundsApply/single", "style": { "navigationBarTitleText": "表单详情页" } }
  110. *
  111. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  112. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  113. */
  114. import get from 'lodash/get'
  115. import set from 'lodash/set'
  116. import moment from 'moment'
  117. import customPageMixins from '@/common/custompage.js'
  118. import uploadFile from '@/components/upload-file2.vue'
  119. export default {
  120. mixins: [customPageMixins],
  121. components:{
  122. uploadFile,
  123. },
  124. data() {
  125. return {
  126. // 页面相关参数
  127. id: null,
  128. mode: null,
  129. edit: null,
  130. ready: false,
  131. create: null,
  132. // 表单数据
  133. current: {},
  134. origin: {},
  135. fileList:[],//附件列表
  136. folderId:null,//附件随机文件夹id
  137. fileTitle:'附件上传',//附件label值
  138. FundsApplyDetail: [],
  139. FundsApplyDetails: {
  140. ProjectContent: '',
  141. Number: '',
  142. Price: '',
  143. Amount: '',
  144. Unit:''
  145. },
  146. // 表单项数据结构
  147. scheme: {
  148. FundsApply: {
  149. EnCode: {
  150. type: 'text',
  151. title: '申报单号'
  152. },
  153. ApplyDept: {
  154. type: "select",
  155. dataSource: '1',
  156. dataSourceId: 'ApplyDept'
  157. },
  158. ApplyTime: {
  159. type: 'datetime',
  160. title: '开始时间',
  161. dateformat: '1',
  162. verify: "NotNull"
  163. },
  164. ApplyUser: {
  165. type: "select",
  166. dataSource: '1',
  167. dataSourceId: 'ApplyUser'
  168. },
  169. IsFixedAssets: {
  170. type: "select",
  171. title: '是否固定资产',
  172. dataSource: '1',
  173. dataSourceId: 'IsFixedAssets',
  174. verify: 'NotNull'
  175. },
  176. Remark: {
  177. type: 'texteditor',
  178. title: '备注',
  179. },
  180. // Remark: {
  181. // type: 'text',
  182. // title: '申请人',
  183. // },
  184. SumAmount: {
  185. type: 'text',
  186. title: '合计'
  187. },
  188. UpperAmount: {
  189. type: 'text',
  190. title: '合计',
  191. verify: 'NotNull'
  192. },
  193. Status: {
  194. type: 'text',
  195. title: '审批状态'
  196. },
  197. Path: {
  198. type: "text",
  199. title: "附件上传",
  200. },
  201. },
  202. },
  203. // 数据源
  204. dataSource: {
  205. FundsApply: {
  206. ApplyDept: [],
  207. ApplyUser: [],
  208. IsFixedAssets: Object.values(this.GET_GLOBAL('dataDictionary').YesOrNoInt).map(t => ({
  209. value: t.value,
  210. text: t.text
  211. })),
  212. Unit:Object.values(this.GET_GLOBAL('dataDictionary').sldw).map(t => ({
  213. value: t.value,
  214. text: t.text
  215. })),
  216. }
  217. },
  218. EnCode: '',
  219. index:0
  220. }
  221. },
  222. async onLoad({
  223. type,
  224. id
  225. }) {
  226. await this.init(type, id)
  227. // console.log(this.dataSource.FundsApply.Unit)
  228. },
  229. methods: {
  230. // 页面初始化
  231. async init(type, id) {
  232. this.folderId=this.GUID();
  233. // console.log('附件随机文件夹id:'+this.folderId);
  234. this.LOADING('加载数据中...')
  235. this.id = id
  236. this.mode = type
  237. this.edit = ['create', 'edit'].includes(this.mode)
  238. // 拉取表单数据,同时拉取所有来自数据源的选单数据
  239. await Promise.all([
  240. this.FETCH_DATASOURCE('classdata').then(result => {
  241. this.dataSource.FundsApply.ApplyDept = result.data.map(t => ({
  242. text: t.name,
  243. value: t.id
  244. }));
  245. }),
  246. this.FETCH_DATASOURCE('teacheruserdata').then(result => {
  247. this.dataSource.FundsApply.ApplyUser = result.data.map(t => ({
  248. text: t.f_realname,
  249. value: t.f_userid
  250. }));
  251. }),
  252. // this.FETCH_DATASOURCE('ConferenceRoom').then(result => {
  253. // this.dataSource.FundsApply.CheckStatus = result.data.map(t => ({ text: t.name, value: t.id }))
  254. // }),
  255. ])
  256. await this.fetchForm()
  257. this.ready = true
  258. this.HIDE_LOADING()
  259. },
  260. // 加载表单数据
  261. async fetchForm() {
  262. if (this.mode === 'create') {
  263. const result = await this.HTTP_GET('/learun/adms/FundsApply/getEnCode')
  264. const source = {
  265. ApplyDept: this.user.departmentId,
  266. ApplyUser: this.user.userId,
  267. ApplyTime: new Date().getTime()
  268. };
  269. let resultres = Object.assign(result, source)
  270. let EnCoderes = {
  271. FundsApply: resultres,
  272. }
  273. this.origin = await this.formatFormData(EnCoderes)
  274. } else {
  275. const result = await this.HTTP_GET('/learun/adms/FundsApply/form', this.id)
  276. result.FundsApply.SumAmount = Number(result.FundsApply.SumAmount).toFixed(2)
  277. this.origin = await this.formatFormData(result)
  278. if(result.FundsApplyDetail.length){
  279. for(let i =0;i<result.FundsApplyDetail.length;i++){
  280. result.FundsApplyDetail[i].Price = Number(result.FundsApplyDetail[i].Price).toFixed(2)
  281. result.FundsApplyDetail[i].Amount = Number(result.FundsApplyDetail[i].Amount).toFixed(2)
  282. }
  283. this.FundsApplyDetail = result.FundsApplyDetail
  284. }
  285. }
  286. this.current = this.COPY(this.origin)
  287. //加载附件值数据
  288. // console.log('附件值赋值前:'+this.getValue('FundsApply.Files'));
  289. if (this.getValue('FundsApply.Path') == ""||this.getValue('FundsApply.Path') == undefined ||this.getValue('FundsApply.Path') == null) {
  290. this.setValue('FundsApply.Path',this.folderId);
  291. // console.log('附件值赋值后:'+this.getValue('FundsApply.Path'));
  292. }else{
  293. this.folderId=this.getValue('FundsApply.Path');
  294. // console.log('文件夹id赋值后:'+this.folderId);
  295. //请求‘获取附件列表’接口
  296. this.fileList =[]
  297. this.fileList = await this.FETCH_FILEList(this.getValue('FundsApply.Path'));
  298. }
  299. },
  300. // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  301. async action(type) {
  302. switch (type) {
  303. case 'edit':
  304. this.edit = true
  305. break
  306. case 'reset':
  307. this.current = this.COPY(this.origin)
  308. this.edit = false
  309. break
  310. case 'save':
  311. const verifyResult = this.verifyForm()
  312. if (verifyResult.length > 0) {
  313. this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  314. return
  315. }
  316. if (this.FundsApplyDetail.some((val) => val.ProjectContent== '')) {
  317. this.CONFIRM('表单验证失败', '明细项目内容不能为空')
  318. return;
  319. }
  320. if (this.FundsApplyDetail.some((val) => val.Number== '')) {
  321. this.CONFIRM('表单验证失败', '明细数量不能为空')
  322. return;
  323. }
  324. if (this.FundsApplyDetail.some((val) => val.Price== '')) {
  325. this.CONFIRM('表单验证失败', '明细单价不能为空')
  326. return;
  327. }
  328. if (this.FundsApplyDetail.some((val) => val.Unit== '')) {
  329. this.CONFIRM('表单验证失败', '明细单位不能为空')
  330. return;
  331. }
  332. if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
  333. return
  334. }
  335. this.LOADING('正在提交...')
  336. let postData = {
  337. strEntity: JSON.stringify(this.current.FundsApply),
  338. fundsApplyDetailList: JSON.stringify(this.FundsApplyDetail)
  339. }
  340. // const postData = await this.getPostData(this.id)
  341. if (this.id) {
  342. postData.keyValue = this.id
  343. }
  344. this.HTTP_POST('/learun/adms/FundsApply/save', postData, '表单提交保存失败')
  345. .then(success => {
  346. this.HIDE_LOADING()
  347. if (!success) {
  348. return
  349. }
  350. this.EMIT('AssetManagementSystemFundsApply-list-change')
  351. // this.NAV_BACK()
  352. uni.navigateBack({})
  353. this.TOAST('提交保存成功')
  354. })
  355. break
  356. case 'delete':
  357. if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
  358. return
  359. }
  360. this.LOADING('提交删除中...')
  361. this.HTTP_POST('/Learun/adms/EducationalAdministration/FundsApply/delete', this.id, '删除失败')
  362. .then(success => {
  363. this.HIDE_LOADING()
  364. if (!success) {
  365. return
  366. }
  367. this.EMIT('AssetManagementSystemFundsApply-list-change')
  368. this.NAV_BACK()
  369. this.this.TOAST('删除成功', 'success')
  370. })
  371. break
  372. default:
  373. break
  374. }
  375. },
  376. // 获取表单值
  377. getValue(path) {
  378. return get(this.current, path)
  379. },
  380. // 设置表单值
  381. setValue(path, val) {
  382. set(this.current, path, val)
  383. },
  384. Statusitem(data) {
  385. if (data == '0') {
  386. return '草稿'
  387. } else if (data == '1') {
  388. return '审批中'
  389. } else if (data == '2') {
  390. return '审批通过'
  391. } else {
  392. return data;
  393. }
  394. },
  395. add(str) {
  396. let jsons = this.COPY(this[str]);
  397. this.FundsApplyDetail.push(jsons)
  398. // console.log(this.FundsApplyDetail)
  399. },
  400. del(str, num) {
  401. let _this = this
  402. this.FundsApplyDetail.splice(num, 1)
  403. let Amounts = _this.FundsApplyDetail.map(item => {
  404. return item.Amount
  405. })
  406. _this.current.FundsApply.SumAmount = _this.sum(Amounts)
  407. _this.current.FundsApply.UpperAmount = _this.smalltoBIG(_this.current.FundsApply.SumAmount)
  408. },
  409. blurChange(item){
  410. let _this = this
  411. item.Price = Number(item.Price).toFixed(2)
  412. if (item.Number && item.Price) {
  413. item.Amount = (item.Number * item.Price).toFixed(2)
  414. // _this.current.SumAmount = item.Number * item.Price
  415. let Amounts = _this.FundsApplyDetail.map(item => {
  416. return Number(item.Amount).toFixed(2)
  417. })
  418. _this.current.FundsApply.SumAmount = Number(_this.sum(Amounts)).toFixed(2)
  419. _this.current.FundsApply.UpperAmount = _this.smalltoBIG(_this.current.FundsApply.SumAmount)
  420. }
  421. },
  422. SumAmountChange(item) {
  423. let _this = this
  424. item.Number = Number(item.Number).toFixed(2)
  425. if (item.Number && item.Price) {
  426. item.Amount = (item.Number * item.Price).toFixed(2)
  427. // _this.current.SumAmount = item.Number * item.Price
  428. let Amounts = _this.FundsApplyDetail.map(item => {
  429. return item.Amount
  430. })
  431. _this.current.FundsApply.SumAmount = Number(_this.sum(Amounts)).toFixed(2)
  432. _this.current.FundsApply.UpperAmount = _this.smalltoBIG(_this.current.FundsApply.SumAmount)
  433. }
  434. },
  435. sum(args) {
  436. if(args == 0){
  437. return ''
  438. }
  439. // var args = arguments,//获取所有的参数
  440. var d = 0, //定义小数位的初始长度,默认为整数,即小数位为0
  441. sum = 0; //定义sum来接收所有数据的和
  442. //循环所有的参数
  443. for (var key in args) { //遍历所有的参数
  444. //把数字转为字符串
  445. var str = '' + args[key];
  446. if (str.indexOf(".") != -1) { //判断数字是否为小数
  447. //获取小数位的长度
  448. var temp = str.split(".")[1].length;
  449. //比较此数的小数位与原小数位的长度,取小数位较长的存储到d中
  450. d = d < temp ? temp : d;
  451. }
  452. }
  453. //计算需要乘的数值
  454. var m = Math.pow(10, d);
  455. //遍历所有参数并相加
  456. for (var key in args) {
  457. sum += args[key] * m;
  458. }
  459. //返回结果
  460. return sum / m;
  461. },
  462. smalltoBIG(n) {
  463. if(n == 0){
  464. return ''
  465. }
  466. var fraction = ['角', '分'];
  467. var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
  468. var unit = [
  469. ['元', '万', '亿'],
  470. ['', '拾', '佰', '仟']
  471. ];
  472. var head = n < 0 ? '欠' : '';
  473. n = Math.abs(n);
  474. var s = '';
  475. for (var i = 0; i < fraction.length; i++) {
  476. s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');
  477. }
  478. s = s || '整';
  479. n = Math.floor(n);
  480. for (var i = 0; i < unit[0].length && n > 0; i++) {
  481. var p = '';
  482. for (var j = 0; j < unit[1].length && n > 0; j++) {
  483. p = digit[n % 10] + unit[1][j] + p;
  484. n = Math.floor(n / 10);
  485. }
  486. s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s;
  487. }
  488. return head + s.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零').replace(/^整$/, '零元整');
  489. },
  490. changeitem(e,item){
  491. // console.log(item)
  492. item.Unit = this.dataSource.FundsApply.Unit[e.detail.value].value
  493. },
  494. mapitem(data){
  495. // let items = this.dataSource.FundsApply.Unit.find(item=>{
  496. // return item.value == data
  497. // }).text
  498. // console.log(items)
  499. return this.dataSource.FundsApply.Unit.find(item=>{
  500. return item.value == data
  501. }).text
  502. }
  503. },
  504. computed: {
  505. // Price(){
  506. // // return this.FundsApplyDetail.filter(item=>item.Amount)
  507. // }
  508. },
  509. created() {
  510. this.user = this.GET_GLOBAL('loginUser');
  511. }
  512. }
  513. </script>
  514. <style lang="less" scoped>
  515. .welT {
  516. font-size: 16px;
  517. line-height: 26px;
  518. padding: 0 12px;
  519. background-color: #ffffff;
  520. padding-bottom: 12px;
  521. }
  522. .welT text {
  523. width: 26px;
  524. height: 26px;
  525. line-height: 24px;
  526. border: 1px solid #efefef;
  527. border-radius: 4px;
  528. float: right;
  529. text-align: center;
  530. color: #999;
  531. }
  532. .welBox {
  533. // margin-top: 10px;
  534. }
  535. .welCon {
  536. padding: 10px;
  537. border: 1px solid #efefef;
  538. padding-top: 15px;
  539. border-radius: 4px;
  540. position: relative;
  541. // background-color: #ffffff;
  542. // margin-top: 15px;
  543. }
  544. .welDel {
  545. border-radius: 50%;
  546. position: absolute;
  547. top: 4px;
  548. left: 0px;
  549. background: #fff;
  550. }
  551. .welDel text {
  552. text-align: center;
  553. width: 26px;
  554. height: 26px;
  555. display: block;
  556. line-height: 24px;
  557. border: 1px solid #efefef;
  558. border-radius: 50%;
  559. }
  560. .welAdd{
  561. border-radius: 50%;
  562. position: absolute;
  563. top: 4px;
  564. right: 0px;
  565. background: #fff;
  566. }
  567. .welAdd text {
  568. text-align: center;
  569. width: 26px;
  570. height: 26px;
  571. display: block;
  572. line-height: 24px;
  573. border: 1px solid #efefef;
  574. border-radius: 50%;
  575. }
  576. .welImgAdd {
  577. text-align: center;
  578. line-height: 0;
  579. }
  580. .passwordDes {
  581. color: #606266;
  582. font-size: 14px;
  583. padding: 8px;
  584. text-indent: 2em;
  585. }
  586. </style>