PatrolWorkOrderForm.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <view>
  3. <cu-custom :backUrl="'/pages/index/index?id=apps'" :isBack="true" bgColor="bg-gradual-blue" >
  4. <block slot="content">建筑垃圾处理</block>
  5. </cu-custom>
  6. <u--form :model="inputForm" labelWidth="100px" class="u-form" labelPosition="left" :rules="rules" ref="inputForm" v-if="!nodeFlag" >
  7. <u-form-item label="巡视工单" prop="no"
  8. :rules="[
  9. ]">
  10. <u--input v-model="inputForm.no" :disabled="true" placeholder="工单编号" clearable></u--input>
  11. </u-form-item>
  12. <u-form-item label="处理单位" borderBottom prop="processingUnit" :required="true">
  13. <jp-picker v-model="inputForm.processingUnit" rangeKey="label" rangeValue="value" :range="[
  14. { label: '审计费', value: '1' },
  15. { label: '工程审核费', value: '2' },
  16. { label: '咨询费', value: '3' },
  17. { label: '预算编制费', value: '4' },
  18. { label: '招标代理费', value: '5' },
  19. { label: '司法鉴定费', value: '6' },
  20. { label: '其他', value: '8' },
  21. { label: '技术服务费', value: '9' },
  22. { label: '鉴证咨询服务*评估费', value: '10' },
  23. { label: '其他咨询服务*专家咨询费', value: '11' },
  24. { label: '会计服务', value: '12' },
  25. { label: '竣工决算编制费', value: '13' },
  26. { label: '*信息技术服务*技术服务费', value: '14' },
  27. ]" ></jp-picker>
  28. </u-form-item>
  29. <u-form-item label="清运专员" prop="clearUserName"
  30. :rules="[
  31. ]">
  32. <u--input v-model="inputForm.clearUserName" :disabled="true" placeholder="清运专员" clearable></u--input>
  33. </u-form-item>
  34. <u-form-item label="联系方式" prop="clearUserMobile"
  35. :rules="[
  36. ]">
  37. <u--input v-model="inputForm.clearUserMobile" :disabled="true" placeholder="联系方式" clearable></u--input>
  38. </u-form-item>
  39. <view class="u-demo-block">
  40. <text class="u-demo-block__title">基础用法</text>
  41. <view class="u-demo-block__content">
  42. <view class="u-page__upload-item">
  43. <u-upload
  44. :fileList="fileList1"
  45. @afterRead="afterRead"
  46. @delete="deletePic"
  47. name="1"
  48. multiple
  49. :maxCount="10"
  50. ></u-upload>
  51. </view>
  52. </view>
  53. </view>
  54. </u--form>
  55. </view>
  56. </template>
  57. <script>
  58. import {mapState, mapMutations, mapActions} from 'vuex'
  59. import * as $auth from "../../common/auth";
  60. export default {
  61. components: {
  62. },
  63. computed: mapState({
  64. userInfo: (state) => state.user.userInfo,
  65. avatar: (state) => state.user.avatar
  66. }),
  67. data () {
  68. return {
  69. fileList1: [],
  70. nodeFlag: false,
  71. inputForm: {
  72. no: '',
  73. processingUnit: '',
  74. clearUserId: '',
  75. clearUserName: '',
  76. clearUserMobile: ''
  77. },
  78. rules: {
  79. /*'billingWorkplaceReal': [
  80. {
  81. required: true,
  82. message: '实际开票单位不能为空',
  83. trigger: ['blur', 'change']
  84. }
  85. ],*/
  86. }
  87. }
  88. },
  89. /*ossService: null,
  90. materialTypeService: null,
  91. wareHouseService: null,
  92. commonApi: null,*/
  93. // 页面加载时执行
  94. created() {
  95. /*this.ossService = new OSSService()
  96. this.commonApi = new CommonApi()
  97. this.materialTypeService = new MaterialTypeService()
  98. this.wareHouseService = new WareHouseService()
  99. this.inputForm.actualDrawerEmailAddress = this.userInfo.email
  100. this.inputForm.handledBy = this.userInfo.name
  101. this.inputForm.handledById = this.userInfo.id
  102. this.inputForm.handledByOffice = this.userInfo.officeDTO.id
  103. this.inputForm.handledByOfficeName = this.userInfo.officeDTO.name*/
  104. },
  105. props: {
  106. status: {
  107. type: String,
  108. default: ''
  109. }
  110. },
  111. watch: {
  112. },
  113. methods: {
  114. init (id) {
  115. this.nodeFlag = true
  116. this.inputForm.id = id
  117. /*if (id) {
  118. financeInvoiceService.queryById(id).then((data) => {
  119. if (this.status === 'testSee') {
  120. this.nodeFlag = true
  121. this.testFlag = true
  122. } else {
  123. this.commonApi.getTaskNameByProcInsId(data.procInsId).then((data) => {
  124. if (this.isNotEmpty(data)) {
  125. if (data === '发起人重新申请' || this.isEmpty(data)) {
  126. this.nodeFlag = false
  127. } else if (data === '发票管理员审核'){
  128. this.nodeFlag = true
  129. this.addFlag = true
  130. }
  131. }else {
  132. this.testFlag = true
  133. this.addFlag = true
  134. console.log('没有')
  135. }
  136. })
  137. }
  138. this.inputForm = this.recover(this.inputForm, data)
  139. if (this.inputForm.workAttachmentDtoList) {
  140. this.inputForm.workAttachmentDtoList.forEach( (item,index) => {
  141. this.$set(this.showFileList, index, true);
  142. })
  143. }
  144. let i = this.inputForm.financeInvoiceBaseDTOList.length
  145. let sun = 0
  146. for (let j = 0; j < i; j++) {
  147. sun = (100*sun + 100* this.inputForm.financeInvoiceBaseDTOList[j].account)/100
  148. }
  149. this.inputForm.accountTotal = sun
  150. this.inputForm.billingDate = this.formatDate(new Date())
  151. if ( !this.nodeFlag && this.status !== 'testSee') {
  152. this.inputForm.financeInvoiceDetailDTOList.push({
  153. code: '',
  154. number: '',
  155. account: sun,
  156. rate: '',
  157. amount: '',
  158. tax: '',
  159. allAmount: ''
  160. })
  161. }
  162. if (!this.isEmpty(this.inputForm.billingWorkplaceRealId)) {
  163. this.bankList = []
  164. workClientService.queryById(this.inputForm.billingWorkplaceRealId).then((data) => {
  165. if (this.isNotEmpty(data.cwWorkClientBillingDTOList)) {
  166. data.cwWorkClientBillingDTOList.forEach(i => {
  167. i.ourBank = i.accountHolder
  168. let test = {label: i.ourBank, value: i.id, account: i.account}
  169. this.bankList.push(test)
  170. this.$set(this.inputForm, 'openBank', i.id);
  171. })
  172. } else {
  173. this.bankList = []
  174. }
  175. })
  176. }
  177. })
  178. }*/
  179. },
  180. formatDate(date) {
  181. const dateNew = new Date(date); // 将日期字符串转换为 Date 对象
  182. const year = dateNew.getFullYear();
  183. const month = (dateNew.getMonth() + 1).toString().padStart(2, '0');
  184. const day = dateNew.getDate().toString().padStart(2, '0');
  185. return `${year}-${month}-${day}`;
  186. },
  187. isEmpty(value) {
  188. let result = false;
  189. if (value == null || value == undefined) {
  190. result = true;
  191. }
  192. if (typeof value == 'string' && (value.replace(/\s+/g, "") == "" || value == "")) {
  193. result = true;
  194. }
  195. if (typeof value == "object" && value instanceof Array && value.length === 0) {
  196. result = true;
  197. }
  198. return result;
  199. },
  200. isNotEmpty (value) {
  201. return !this.isEmpty(value)
  202. },
  203. /**
  204. * 判断是否为空
  205. */
  206. isNull(val) {
  207. if (val instanceof Array) {
  208. if (val.length === 0) return true;
  209. } else if (val instanceof Object) {
  210. if (JSON.stringify(val) === "{}") return true;
  211. } else {
  212. if (
  213. val === "null" ||
  214. val == null ||
  215. val === "undefined" ||
  216. val === undefined ||
  217. val === ""
  218. )
  219. return true;
  220. return false;
  221. }
  222. return false;
  223. },
  224. formatDateNew(date) {
  225. const year = date.getFullYear();
  226. const month = (date.getMonth() + 1).toString().padStart(2, '0');
  227. const day = date.getDate().toString().padStart(2, '0');
  228. const hours = date.getHours().toString().padStart(2, '0');
  229. const minutes = date.getMinutes().toString().padStart(2, '0');
  230. const seconds = date.getSeconds().toString().padStart(2, '0');
  231. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  232. },
  233. saveForm(callback) {
  234. return new Promise((resolve, reject) => {
  235. // 表单规则验证
  236. // ...
  237. let errors = [];
  238. /*if (errors.length > 0) {
  239. // 存在错误,显示提示信息
  240. errors.forEach(error => {
  241. uni.showToast({
  242. title: error,
  243. icon: 'none',
  244. duration: 2000
  245. });
  246. });
  247. reject('Form validation failed');
  248. } else {
  249. this.inputForm.account = this.inputForm.accountTotal
  250. // 所有验证通过,执行保存操作
  251. this.$refs.inputForm.validate().then(() => {
  252. uni.showLoading();
  253. this.inputForm.status = '2';
  254. financeInvoiceService.saveForm(this.inputForm).then(data => {
  255. callback(data.businessTable, data.businessId);
  256. resolve('Form saved successfully');
  257. }).catch(error => {
  258. reject('Save operation failed');
  259. });
  260. }).catch(() => {
  261. reject('Form validation failed');
  262. });
  263. }*/
  264. });
  265. },
  266. // 修改状态
  267. /*async updateStatusById (type, callback) {
  268. if (type === 'reject' || type === 'reback') {
  269. financeInvoiceService.queryById(this.inputForm.id).then((data) => {
  270. if (data.status !== '2') { // status的值不等于“审核中”,就弹出提示
  271. this.loading = false
  272. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  273. throw new Error()
  274. } else {
  275. if (type === 'reject') {
  276. // 驳回
  277. this.inputForm.status = '4'
  278. }
  279. if (type === 'reback') {
  280. // 撤回
  281. this.inputForm.status = '3'
  282. }
  283. if (type === 'reject' || type === 'reback') {
  284. let param = {status: this.inputForm.status, id: this.inputForm.id}
  285. financeInvoiceService.updateStatusById(param).then(() => {
  286. this.loading = false
  287. callback()
  288. })
  289. }
  290. }
  291. })
  292. } else if (type === 'hold') {
  293. financeInvoiceService.queryById(this.inputForm.id).then((data) => {
  294. if (data.status !== '4') { // status的值不等于“驳回”就弹出提示
  295. this.loading = false
  296. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  297. throw new Error()
  298. } else {
  299. // 终止
  300. let param = {status: '1', id: this.inputForm.id}
  301. financeInvoiceService.updateStatusById(param).then(() => {
  302. this.loading = false
  303. callback()
  304. })
  305. }
  306. })
  307. }
  308. },*/
  309. /*reapplyForm (callback) {
  310. this.loading = true
  311. financeInvoiceService.queryById(this.inputForm.id).then((data) => {
  312. if (data.status !== '4') { // 审核状态不是“驳回”,就弹出提示
  313. this.loading = false
  314. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  315. throw new Error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  316. } else {
  317. this.startFormTrue(callback)
  318. }
  319. })
  320. },*/
  321. // 送审
  322. /*async startFormTrue (callback) {
  323. this.$refs.inputForm.validate().then(res => {
  324. this.inputForm.status = '2'
  325. financeInvoiceService.saveForm(this.inputForm).then((data) => {
  326. this.inputForm.id = data.businessId
  327. callback(data.businessTable, data.businessId, this.inputForm)
  328. this.$refs.inputForm.resetFields()
  329. this.loading = false
  330. }).catch(() => {
  331. this.$refs.inputForm.resetFields()
  332. }).catch((e) => {
  333. })
  334. })
  335. },*/
  336. // 通过
  337. /*async agreeForm (callback) {
  338. return new Promise((resolve, reject) => {
  339. // 表单规则验证
  340. // ...
  341. let errors = [];
  342. let acc = 0
  343. if (errors.length > 0) {
  344. // 存在错误,显示提示信息
  345. errors.forEach(error => {
  346. uni.showToast({
  347. title: error,
  348. icon: 'none',
  349. duration: 2000
  350. });
  351. });
  352. reject('Form validation failed');
  353. } else {
  354. // 所有验证通过,执行保存操作
  355. this.$refs.inputForm.validate().then(res => {
  356. this.inputForm.status = '5'
  357. financeInvoiceService.saveForm(this.inputForm).then((data) => {
  358. callback(data.businessTable, data.businessId, this.inputForm)
  359. this.$refs.inputForm.resetFields()
  360. this.loading = false
  361. }).catch(() => {
  362. this.loading = false
  363. this.$refs.inputForm.resetFields()
  364. })
  365. })
  366. }
  367. });
  368. },*/
  369. // 删除图片
  370. deletePic(event) {
  371. this[`fileList${event.name}`].splice(event.index, 1)
  372. },
  373. // 新增图片
  374. async afterRead(event) {
  375. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  376. let lists = [].concat(event.file)
  377. let fileListLen = this[`fileList${event.name}`].length
  378. lists.map((item) => {
  379. this[`fileList${event.name}`].push({
  380. ...item,
  381. status: 'uploading',
  382. message: '上传中'
  383. })
  384. })
  385. for (let i = 0; i < lists.length; i++) {
  386. const result = await this.uploadFilePromise(lists[i].url)
  387. let item = this[`fileList${event.name}`][fileListLen]
  388. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  389. status: 'success',
  390. message: '',
  391. url: result
  392. }))
  393. fileListLen++
  394. }
  395. },
  396. uploadFilePromise(url) {
  397. console.log($auth.getUserToken())
  398. return new Promise((resolve, reject) => {
  399. let a = uni.uploadFile({
  400. url: 'http://localhost:8000/app/file/upload', // 仅为示例,非真实的接口地址
  401. filePath: url,
  402. name: 'file',
  403. formData: {
  404. user: this.$store.state.user.userInfo
  405. },
  406. header: {
  407. 'token': $auth.getUserToken(),
  408. },
  409. success: (res) => {
  410. setTimeout(() => {
  411. resolve(res.data.data);
  412. }, 1000);
  413. },
  414. fail: (err) => {
  415. console.error('Upload failed:', err);
  416. }
  417. });
  418. })
  419. },
  420. }
  421. }
  422. </script>
  423. <style>
  424. .cu-form-group .title {
  425. min-width: calc(4em + 40px);
  426. }
  427. /* 样式示例,您可能需要根据实际情况调整 */
  428. .upload-demo {
  429. width: 40%;
  430. }
  431. .button-container {
  432. margin-top: 10px;
  433. text-align: right;
  434. }
  435. </style>