综合办公系统
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

declare.vue 13KB

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