综合办公系统
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.

declare.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. <template>
  2. <view class="form-container">
  3. <!-- 表单标题 -->
  4. <view class="form-title">
  5. <text class="title-text">工作填报</text>
  6. <view class="title-line"></view>
  7. </view>
  8. <!-- 表单内容 -->
  9. <uni-forms ref="form" :modelValue="formData" :rules="rules" label-position="top" label-width="150"
  10. class="custom-form">
  11. <flow-note :taskForm="taskForm"></flow-note>
  12. <!-- 当前节点 -->
  13. <uni-forms-item label="当前节点" class="form-item" v-if="taskName">
  14. <uni-tag :inverted="true" type="primary" :text="taskName"></uni-tag>
  15. </uni-forms-item>
  16. <!-- 流程发起人 -->
  17. <uni-forms-item label="填报人" class="form-item">
  18. <b style="font-size:30rpx;">{{ applierUserName }}</b>
  19. </uni-forms-item>
  20. <!-- 填报日期 -->
  21. <uni-forms-item label="填报日期" class="form-item">
  22. <text>{{ formData.submitTime }}</text>
  23. </uni-forms-item>
  24. <!-- 是否零星项目 -->
  25. <uni-forms-item label="是否零星项目" class="form-item" name="isScattered">
  26. <uni-data-checkbox v-model="isScattered" :localdata="isScatteredOptions"></uni-data-checkbox>
  27. </uni-forms-item>
  28. <!-- 选择项目 -->
  29. <uni-forms-item label="选择项目" required class="form-item" v-if="!isScattered" name="projectId">
  30. <!-- <ProjectPicker v-model="formData.projectId" placeholder="请选择项目" :labelKey="'projectName'"
  31. :valueKey="'projectId'" @change="handleProjectChange"
  32. :customStyle="{ borderColor: '#e5e5e5', borderRadius: '8px' }" v-if="taskName == '工作填报'" /> -->
  33. <!-- <ProjectInfo :project="projectObj" v-else></ProjectInfo> -->
  34. <u-button type="primary" @click="openProject = true" v-if="taskName == '工作填报'">选择项目</u-button>
  35. <ProjectPicker :visible.sync="openProject" :selected.sync="selectedProject" @confirm="handleConfirm" />
  36. <ProjectInfo :project="projectObj"></ProjectInfo>
  37. </uni-forms-item>
  38. <!-- 工作类别 -->
  39. <uni-forms-item label="工作类别" required class="form-item" name="workType">
  40. <uni-data-select :disabled="taskName != '工作填报'" :clear="taskName == '工作填报'" v-model="formData.workType"
  41. :localdata="workTypeColumns" @change="bindWorkTypeChange"></uni-data-select>
  42. </uni-forms-item>
  43. <!-- 工作细项 -->
  44. <uni-forms-item label="工作细项" required class="form-item" name="workItem">
  45. <picker @change="bindWorkItemChange" :value="formData.workItem" :range="workItemList"
  46. :disabled="taskName != '工作填报'">
  47. <view class="uni-input">
  48. <uni-easyinput type="text" :disabled="taskName != '工作填报'" v-model="formData.workItem"
  49. @click="showType = true" placeholder="请选择" :styles="inputStyle" />
  50. </view>
  51. </picker>
  52. </uni-forms-item>
  53. <!-- 具体内容 -->
  54. <uni-forms-item label="具体内容" required class="form-item" name="workContent">
  55. <uni-easyinput :disabled="taskName != '工作填报'" type="textarea" v-model="formData.workContent"
  56. placeholder="请输入具体工作内容" :styles="textareaStyle" />
  57. </uni-forms-item>
  58. <!-- 工天 -->
  59. <uni-forms-item label="工天" required class="form-item" name="workLoad">
  60. <uni-easyinput :disabled="taskName != '工作填报'" type="number" v-model="formData.workLoad" placeholder="请输入所需工天"
  61. :styles="inputStyle">
  62. <text slot="right" class="unit">天</text>
  63. </uni-easyinput>
  64. </uni-forms-item>
  65. <uni-forms-item label="系数" required class="form-item" name="coefficient" v-if="taskName != '工作填报'">
  66. <uni-easyinput type="number" v-model="formData.coefficient" placeholder="请输入系数" :styles="inputStyle"
  67. @blur="countMoney" @clear="countMoney" :disabled="!taskName || taskName == '填报人确认'">
  68. </uni-easyinput>
  69. </uni-forms-item>
  70. <uni-forms-item label="工天单价" class="form-item" v-if="taskName != '工作填报'">
  71. <u-tag :text="formData.price + '/人天'" type="success" plain></u-tag>
  72. </uni-forms-item>
  73. <uni-forms-item label="预估绩效" class="form-item" v-if="taskName != '工作填报'">
  74. <u-tag :text="'¥' + money" type="primary" plain></u-tag>
  75. </uni-forms-item>
  76. <!-- 提交按钮 -->
  77. <view v-if="taskName">
  78. <button class="save-btn" @click="save">保存</button>
  79. <button class="submit-btn margin-top-xs" type="primary" @click="submitForm"
  80. v-if="taskName == '工作填报'">提交</button>
  81. <button class="submit-btn margin-top-xs" type="primary" @click="submitForm" v-else>确认审核</button>
  82. </view>
  83. </uni-forms>
  84. <uv-modal ref="popModal" title="提示" content='是否提交表单?' :showCancelButton="true" @confirm="confirmSubmit"></uv-modal>
  85. </view>
  86. </template>
  87. <script>
  88. import ProjectPicker from '@/pages/components/ProjectPicker.vue';
  89. import ProjectInfo from '@/pages/components/ProjectInfo.vue';
  90. import { listPrice, getWorkTypeList, getWorkItemList } from '@/api/oa/price/price'
  91. import { listProject, submitProject, modifyProject, delProject } from "@/api/oa/project/project";
  92. import { listDeclare, getDeclare, addDeclare, updateDeclare } from '@/api/oa/declare/declare';
  93. import { parseTime } from "@/utils/common.js"
  94. import { complete, getNextFlowNode } from "@/api/flowable/todo";
  95. import { getUsersDeptLeader, getUsersDeptLeaderByDept, getUsersManageLeaderByDept } from "@/api/system/post.js";
  96. import FlowNote from '@/pages/components/flowNote.vue';
  97. export default {
  98. components: {
  99. ProjectPicker,
  100. ProjectInfo,
  101. FlowNote
  102. },
  103. props: {
  104. taskForm: Object,
  105. taskName: String, // 当前节点
  106. startUserName: String, // 流程发起人
  107. },
  108. created() {
  109. this.applierUserName = this.startUserName;
  110. this.getProjectList();
  111. this.initForm();
  112. if (this.taskName != '工作填报') {
  113. this.isScatteredOptions.map(item => item.disable = true)
  114. }
  115. uni.setNavigationBarTitle({
  116. title: '工作填报'
  117. });
  118. },
  119. data() {
  120. return {
  121. applierUserName: '',
  122. openProject: false,
  123. selectedProject: null,
  124. isScattered: 0,
  125. formData: {
  126. userId: null,
  127. projectId: '',
  128. workType: '',
  129. workItem: '',
  130. workContent: '',
  131. workLoad: '',
  132. price: 216,
  133. submitTime: '',
  134. coefficient: undefined,
  135. },
  136. money: '',
  137. rules: {
  138. projectId: {
  139. rules: [{
  140. required: true,
  141. errorMessage: '请选择项目',
  142. },]
  143. },
  144. workType: {
  145. rules: [{
  146. required: true,
  147. errorMessage: '请选择工作类别',
  148. },]
  149. },
  150. workItem: {
  151. rules: [{
  152. required: true,
  153. errorMessage: '请选择工作细项',
  154. },]
  155. },
  156. workContent: {
  157. rules: [{
  158. required: true,
  159. errorMessage: '请输入具体内容',
  160. },]
  161. },
  162. workLoad: {
  163. rules: [{
  164. required: true,
  165. errorMessage: '请输入工作量',
  166. },]
  167. },
  168. coefficient: {
  169. rules: [{
  170. required: true,
  171. errorMessage: '请输入系数',
  172. },]
  173. }
  174. },
  175. projectObj: {},
  176. isScatteredOptions: [{
  177. text: '否',
  178. value: 0,
  179. disable: false
  180. }, {
  181. text: '是',
  182. value: 1,
  183. disable: false
  184. }],
  185. projects: [],
  186. projectIndex: -1,
  187. inputStyle: {
  188. borderColor: '#e5e5e5',
  189. borderRadius: '8px'
  190. },
  191. textareaStyle: {
  192. borderColor: '#e5e5e5',
  193. borderRadius: '8px',
  194. height: '100px'
  195. },
  196. showType: false,
  197. workTypeColumns: [{
  198. text: '外业',
  199. value: '外业',
  200. },
  201. {
  202. text: '内业',
  203. value: '内业'
  204. }
  205. ],
  206. workItemList: [],
  207. hasForm: false,
  208. show: false,
  209. };
  210. },
  211. methods: {
  212. handleConfirm(project) {
  213. this.selectedProject = project;
  214. this.projectObj = project;
  215. },
  216. initForm() {
  217. if (this.taskName == '工作填报') {
  218. this.formData.submitTime = parseTime(new Date(), "{y}-{m}-{d}");
  219. this.formData.userId = this.$store.getters.userId;
  220. }
  221. getDeclare(this.taskForm.formId).then(res => {
  222. if (res.data) {
  223. this.hasForm = true;
  224. this.formData = res.data;
  225. if (!this.applierUserName) {
  226. this.applierUserName = this.formData.user.nickName;
  227. }
  228. if (res.data.projectId) {
  229. this.isScattered = 0;
  230. } else {
  231. this.isScattered = 1;
  232. }
  233. res.data.project.projectLeader = res.data.projectLeader
  234. this.projectObj = res.data.project;
  235. this.selectedProject = res.data.project;
  236. this.bindWorkTypeChange(this.formData.workType);
  237. this.countMoney();
  238. } else {
  239. this.hasForm = false;
  240. }
  241. })
  242. },
  243. bindProjectChange(e) {
  244. this.projectIndex = e.detail.value;
  245. this.formData.project = this.projects[this.projectIndex];
  246. },
  247. bindWorkTypeChange(e) {
  248. listPrice({
  249. workType: e,
  250. pageNum: 1,
  251. pageSize: 9999
  252. }).then(res => {
  253. if (res.code == 200) {
  254. let data = res.rows;
  255. let list = [];
  256. for (let d of data) {
  257. list.push(d.workItem)
  258. }
  259. if (e == '内业') {
  260. list.push('其他')
  261. }
  262. this.workItemList = [...new Set(list)];
  263. }
  264. })
  265. },
  266. bindWorkItemChange(e) {
  267. this.formData.workItem = this.workItemList[e.detail.value];
  268. },
  269. handleRadioChange(e) {
  270. this.formData.isScattered = e.detail.value;
  271. },
  272. handleProjectChange(row) {
  273. },
  274. getProjectList() {
  275. listProject({
  276. pageNum: 1,
  277. pageSize: 10
  278. }).then(res => {
  279. this.projects = res.rows
  280. })
  281. },
  282. countMoney() {
  283. let result = Number(this.formData.price) * Number(this.formData.workLoad) * Number(this.formData.coefficient)
  284. this.money = result.toFixed(2)
  285. },
  286. async save() {
  287. if (!this.isScattered) {
  288. this.formData.projectId = this.projectObj.projectId;
  289. } else {
  290. this.formData.projectId = ''
  291. }
  292. if (this.hasForm) {
  293. let updateRes = await updateDeclare(this.formData);
  294. } else {
  295. this.formData.formId = this.taskForm.formId;
  296. let addRes = await addDeclare(this.formData);
  297. if (addRes.code == 200) {
  298. this.hasForm = true;
  299. } else {
  300. this.hasForm = false;
  301. }
  302. }
  303. uni.showToast({
  304. title: '保存成功',
  305. icon: 'success'
  306. });
  307. },
  308. submitForm() {
  309. this.$refs.form.validate().then(res => {
  310. this.taskForm.variables.skip = false;
  311. if (!this.projectObj.projectLeader) {
  312. if (this.isScattered == 0) {
  313. this.$message.error('该项目未指定项目负责人,无法提交。')
  314. return
  315. }
  316. }
  317. this.$refs.popModal.open();
  318. }).catch(err => {
  319. console.log('表单错误信息:', err);
  320. })
  321. },
  322. confirmSubmit() {
  323. if (this.taskName == '工作填报') {
  324. this.declareSubmit();
  325. } else if (this.taskName == '项目负责人审核' || this.taskName == '部门负责人审核') {
  326. this.approveForm();
  327. } else {
  328. this.confirmForm();
  329. }
  330. },
  331. async declareSubmit() {
  332. if (this.isScattered == 0) {
  333. let approval = this.projectObj.projectLeader;
  334. this.taskForm.variables.approval = approval
  335. } else {
  336. let resData = await getUsersDeptLeader({
  337. userId: this.form.userId
  338. });
  339. if (resData.data) {
  340. this.taskForm.variables.approval = resData.data.userId
  341. this.taskForm.variables.skip = true;
  342. }
  343. }
  344. if (this.hasForm) {
  345. updateDeclare(this.formData);
  346. } else {
  347. this.formData.formId = this.taskForm.formId;
  348. addDeclare(this.formData);
  349. }
  350. this.handleComplete(this.taskForm);
  351. },
  352. async approveForm() {
  353. if (this.taskName == '项目负责人审核') {
  354. this.formData.checkStatus = '1';
  355. updateDeclare(this.formData);
  356. let resData = await getUsersDeptLeader({
  357. userId: this.formData.userId
  358. });
  359. if (resData.data) {
  360. this.taskForm.variables.approval = resData.data.userId;
  361. this.handleComplete(this.taskForm);
  362. }
  363. } else if (this.taskName == '部门负责人审核') {
  364. this.formData.checkStatus = '1';
  365. this.formData.auditStatus = '1';
  366. updateDeclare(this.formData);
  367. this.taskForm.variables.approval = this.formData.userId;
  368. this.handleComplete(this.taskForm);
  369. }
  370. },
  371. confirmForm() {
  372. this.$modal.confirm('最后一个节点,提交将结束流程,是否提交?').then(() => {
  373. this.formData.confirmStatus = '1';
  374. updateDeclare(this.formData);
  375. this.handleComplete(this.taskForm);
  376. })
  377. },
  378. handleComplete(taskForm) {
  379. const params = {
  380. taskId: this.taskForm.taskId
  381. };
  382. getNextFlowNode(params).then(() => {
  383. complete(taskForm).then(response => {
  384. uni.showToast({
  385. title: response.msg,
  386. icon: 'success'
  387. });
  388. setTimeout(() => {
  389. uni.switchTab({
  390. url: '/pages/message/index'
  391. })
  392. }, 500);
  393. })
  394. })
  395. },
  396. }
  397. };
  398. </script>
  399. <style lang="scss" scoped>
  400. .form-container {
  401. padding: 20px;
  402. background-color: #f8f8f8;
  403. }
  404. .form-title {
  405. margin-bottom: 15px;
  406. text-align: center;
  407. .title-text {
  408. font-size: 20px;
  409. font-weight: bold;
  410. color: #333;
  411. }
  412. .title-line {
  413. width: 50px;
  414. height: 2px;
  415. background-color: #007AFF;
  416. margin: 8px auto;
  417. }
  418. }
  419. .custom-form {
  420. background-color: #fff;
  421. padding: 15px;
  422. border-radius: 12px;
  423. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  424. }
  425. .form-item {
  426. margin-bottom: 20px;
  427. ::v-deep .uni-forms-item__label {
  428. font-weight: 500;
  429. color: #666;
  430. padding-bottom: 8px;
  431. }
  432. }
  433. .picker {
  434. width: 100%;
  435. padding: 10px;
  436. border: 1px solid #e5e5e5;
  437. border-radius: 8px;
  438. display: flex;
  439. align-items: center;
  440. justify-content: space-between;
  441. color: #333;
  442. }
  443. .radio-label {
  444. margin-right: 25px;
  445. display: inline-flex;
  446. align-items: center;
  447. }
  448. .unit {
  449. color: #999;
  450. padding: 0 10px;
  451. }
  452. </style>