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

moneyTable.vue 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <div style="padding: 0 20px;">
  3. <el-form :model="form">
  4. <el-form-item>
  5. <table class="mb20" border="1">
  6. <tr class="head">
  7. <td colspan="11">项目计划工作量</td>
  8. </tr>
  9. <tr class="content-head">
  10. <td>序号</td>
  11. <td colspan="2">工作内容</td>
  12. <td>等级或比例尺</td>
  13. <td>单位</td>
  14. <td>工作量</td>
  15. <td>要求完成时间</td>
  16. <td colspan="4">备注</td>
  17. </tr>
  18. <tr v-for="(work, index) in workList" :key="index">
  19. <td>{{ index + 1 }}</td>
  20. <td colspan="2">{{ work.content }}</td>
  21. <td>{{ work.scale }}</td>
  22. <td>{{ work.unit }}</td>
  23. <td>{{ work.workload }}</td>
  24. <td> {{ work.deadline }}</td>
  25. <td colspan="4">{{ work.remark }}</td>
  26. </tr>
  27. </table>
  28. </el-form-item>
  29. <el-form-item>
  30. <table border="1">
  31. <tr class="head">
  32. <td colspan="11">内业预算绩效</td>
  33. </tr>
  34. <tr class="content-head">
  35. <td style="width: 100px;">工作简述</td>
  36. <!-- <td style="width: 100px;">工作类别</td> -->
  37. <td style="width: 100px;">工作内容</td>
  38. <td style="width: 100px;">内容细项</td>
  39. <td style="width: 80px;">比例尺/等级</td>
  40. <td style="width: 80px;">地类类型</td>
  41. <td style="width: 50px;">单价</td>
  42. <td style="width: 50px;">单位</td>
  43. <td style="width: 50px;">数量</td>
  44. <td style="width: 50px;">系数</td>
  45. <td style="width: 100px;">备注</td>
  46. <td style="width: 50px;">金额</td>
  47. </tr>
  48. <tr v-for="(work, index) in contentList" :key="index">
  49. <!-- 工作简述 -->
  50. <td style="position:relative;">
  51. <div class="delete-btn" @click="deletWorkItem(index)">
  52. <i class="el-icon-circle-close"></i>
  53. </div>
  54. <el-input type="textarea" v-model="work.content"></el-input>
  55. </td>
  56. <!-- 选择工作类别 -->
  57. <!-- <td>
  58. <el-select v-model="work.workType" :style="{ width: '100%' }"
  59. @change="getWorkItemList(work, work.workType)">
  60. <el-option v-for="item in workTypeList" :key="item.value" :label="item.label" :value="item.value">
  61. </el-option>
  62. </el-select>
  63. </td> -->
  64. <!-- 选择工作项目 -->
  65. <td>
  66. <el-select v-model="work.workItem" :style="{ width: '100%' }" :remote="true"
  67. @change="getScaleGradeList(work, work.workItem)">
  68. <el-option v-for="item in workItemList" :key="item.value" :label="item.label" :value="item.value">
  69. </el-option>
  70. </el-select>
  71. </td>
  72. <!-- 选择内容细项 -->
  73. <td>
  74. <el-select v-model="work.subItem" :style="{ width: '100%' }" :remote="true"
  75. @change="setRemarkBySubItem(work, work.subItem)">
  76. <el-option v-for="item in work.workSelect.subItemList" :key="item.value" :label="item.label"
  77. :value="item.value">
  78. </el-option>
  79. </el-select>
  80. </td>
  81. <!-- 选择比例尺/等级 -->
  82. <td>
  83. <el-select v-model="work.scaleGrade" :style="{ width: '100%' }"
  84. @change="getUnitPrice(work, work.workItem, work.subItem, work.scaleGrade, work.groundType)">
  85. <el-option v-for="item in work.workSelect.scaleGradeList" :key="item.value" :label="item.label"
  86. :value="item.value">
  87. </el-option>
  88. </el-select>
  89. </td>
  90. <!-- 选择地类 -->
  91. <td>
  92. <el-select v-model="work.groundType" :style="{ width: '100%' }"
  93. @change="getUnitPrice(work, work.workItem, work.subItem, work.scaleGrade, work.groundType)">
  94. <el-option key="一般地类" label="一般地类" value="0">
  95. </el-option>
  96. <el-option key="复杂地类" label="复杂地类" value="1">
  97. </el-option>
  98. </el-select>
  99. </td>
  100. <!-- 单价 -->
  101. <td>
  102. {{ work.price }}
  103. </td>
  104. <!-- 单位 -->
  105. <td>
  106. {{ work.unit }}
  107. </td>
  108. <!-- 数量 -->
  109. <td>
  110. <el-input-number :controls="false" :style="{ width: '100%' }" v-model="work.workload"
  111. @change="getTotal(work)"></el-input-number>
  112. </td>
  113. <!-- 系数 -->
  114. <td>
  115. <el-input-number v-model="work.coefficient" :controls="false" :precision="2" :step="0.01" :max="10"
  116. @blur="getTotal(work)" style="width:60px;">
  117. </el-input-number>
  118. <!-- <el-tooltip content="系数备注" placement="right-start">
  119. <el-button icon="el-icon-info" type="text" @click="getCoefficientRemark(work.workType)"></el-button>
  120. </el-tooltip> -->
  121. </td>
  122. <!-- 备注 -->
  123. <td>
  124. <el-input type="textarea" v-model="work.remark"></el-input>
  125. </td>
  126. <!-- 总额 -->
  127. <td>
  128. {{ work.settle }}
  129. </td>
  130. </tr>
  131. <tr>
  132. <td colspan="10">内业预算绩效总额</td>
  133. <td colspan="1">{{ Number(settle).toFixed(2) }}</td>
  134. </tr>
  135. </table>
  136. <el-button icon="el-icon-plus" plain type="primary" size="mini" @click="addWorkList"></el-button>
  137. </el-form-item>
  138. </el-form>
  139. </div>
  140. </template>
  141. <script>
  142. import { listProjectWork } from "@/api/oa/project/projectWork";
  143. import { getPriceRemarkByWorkType } from '@/api/oa/price/price'
  144. import { listBudgetSettle, addBudgetSettle, delBudgetSettle } from "@/api/oa/budget/budgetSettle.js";
  145. // import { getWorkTypeList, getWorkItemList, getSubItemList, getScaleGradeList, getUnitPrice } from '@/api/oa/price/price'
  146. import { getWorkTypeList, getWorkItemList, getSubItemList, getScaleGradeList, getUnitPrice } from '@/api/oa/price/checkPrice'
  147. export default {
  148. props: {
  149. projectId: {
  150. type: String,
  151. default: ''
  152. },
  153. budgetId: {
  154. type: String,
  155. default: ''
  156. },
  157. },
  158. data() {
  159. return {
  160. form: {},
  161. workList: [],//项目概况工作列表
  162. workTypeList: [],
  163. workItemList: [],
  164. contentList: [
  165. {
  166. content: '',
  167. workType: '',
  168. workItem: '',
  169. subItem: '',
  170. scaleGrade: '',
  171. groundType: '0',
  172. price: '',
  173. unit: '',
  174. workload: '',
  175. coefficient: 1,
  176. settle: 0,
  177. workSelect: {
  178. // 项目列表
  179. projectList: [],
  180. // 工作类别列表
  181. workTypeList: [],
  182. // 工作项目
  183. workItemList: [],
  184. // 项目细项
  185. subItemList: [],
  186. // 比例尺
  187. scaleGradeList: [],
  188. }
  189. }
  190. ],
  191. settle: 0,
  192. }
  193. },
  194. watch: {
  195. budgetId() {
  196. this.initTable();
  197. },
  198. settle(newval) {
  199. this.$emit('settleExpense', newval)
  200. },
  201. contentList: {
  202. handler(newVal) {
  203. let list = newVal.filter(item => item.checkPriceId);
  204. this.$emit('contentList', list)
  205. },
  206. immediate: true, // 立即生效
  207. deep: true //监听对象或数组的时候,要用到深度监听
  208. }
  209. },
  210. created() {
  211. this.initTable();
  212. // this.initWorkTypeList();
  213. this.initWorkItemList();
  214. },
  215. methods: {
  216. initTable() {
  217. if (this.projectId != '') {
  218. listProjectWork({ pageSize: 999, projectId: this.projectId }).then(res => {
  219. this.workList = res.rows;
  220. })
  221. }
  222. if (this.budgetId != '') {
  223. listBudgetSettle({ pageSize: 100, budgetId: this.budgetId }).then(res => {
  224. if (res.total != 0) {
  225. this.contentList = res.rows;
  226. this.initContenList();
  227. this.getSettleSum();
  228. }
  229. })
  230. }
  231. },
  232. initContenList() {
  233. for (let c of this.contentList) {
  234. this.$set(c, 'workSelect', {
  235. // 项目列表
  236. projectList: [],
  237. // 工作类别列表
  238. workTypeList: [],
  239. // 工作项目
  240. workItemList: [],
  241. // 项目细项
  242. subItemList: [],
  243. // 比例尺
  244. scaleGradeList: [],
  245. workTypeLoading: true,
  246. subItemLoading: true,
  247. scaleGradeLoading: true,
  248. })
  249. if (c.checkPriceId) {
  250. this.$set(c, 'workType', c.cmcCheckPrice.workType)
  251. this.$set(c, 'workItem', c.cmcCheckPrice.workItem)
  252. this.$set(c, 'subItem', c.cmcCheckPrice.subItem)
  253. this.$set(c, 'scaleGrade', c.cmcCheckPrice.scaleGrade)
  254. this.$set(c, 'unit', c.cmcCheckPrice.unit)
  255. if (c.groundType == '0') {
  256. this.$set(c, 'price', c.cmcCheckPrice.commonPrice)
  257. } else {
  258. this.$set(c, 'price', c.cmcCheckPrice.complexPrice)
  259. }
  260. } else {
  261. this.$set(c, 'workType', c.cmcPrice.workType)
  262. this.$set(c, 'scaleGrade', c.cmcPrice.scaleGrade)
  263. this.$set(c, 'workItem', c.cmcPrice.workItem)
  264. this.$set(c, 'unit', c.cmcPrice.unit)
  265. this.$set(c, 'groundType', c.cmcPrice.groundType)
  266. if (c.groundType == '0') {
  267. this.$set(c, 'price', c.cmcPrice.commonPrice)
  268. } else {
  269. this.$set(c, 'price', c.cmcPrice.complexPrice)
  270. }
  271. }
  272. this.getTotal(c)
  273. }
  274. },
  275. /* 获取工作类别 */
  276. initWorkTypeList() {
  277. getWorkTypeList().then(res => {
  278. if (res) {
  279. this.workTypeList = this.setArray(res);
  280. }
  281. });
  282. },
  283. initWorkItemList() {
  284. getWorkItemList({ workType: '内业' }).then(res => {
  285. if (res) {
  286. this.workItemList = this.setArray(res);
  287. }
  288. })
  289. },
  290. /* 获取工作项目 */
  291. getWorkItemList(work, workType) {
  292. getWorkItemList({ workType: workType }).then(res => {
  293. if (res) {
  294. let workItemList = this.setArray(res);
  295. work.workSelect.workItemList = workItemList;
  296. work.workItem = workItemList[0].label;
  297. work.subItem = '';
  298. this.getScaleGradeList(work, work.workItem);
  299. }
  300. })
  301. },
  302. // 获取内容细项
  303. getWorkSubItemList(work, workItem) {
  304. getSubItemList({ workItem }).then(res => {
  305. if (res) {
  306. let subItemList = this.setArray(res);
  307. work.workSelect.subItemList = subItemList;
  308. this.$set(work, 'subItem', subItemList[0].label);
  309. this.$set(work, 'remark', subItemList[0].remark);
  310. }
  311. })
  312. },
  313. // 设置备注
  314. setRemarkBySubItem(work) {
  315. this.getUnitPrice(work, work.workItem, work.subItem, work.scaleGrade, work.groundType);
  316. },
  317. /* 获取比例尺 */
  318. getScaleGradeList(work, workItem) {
  319. this.getWorkSubItemList(work, workItem);
  320. if (work.scale) {
  321. this.$set(work, 'scaleGrade', work.scale);
  322. if (work.groundType == undefined) {
  323. this.$set(work, 'groundType', '0');
  324. }
  325. this.getUnitPrice(work, work.workItem, work.subItem, work.scaleGrade, work.groundType);
  326. } else {
  327. getScaleGradeList({ workItem }).then(res => {
  328. if (res) {
  329. let scaleGradeList = this.setArray(res);
  330. work.workSelect.scaleGradeLoading = false;
  331. work.workSelect.scaleGradeList = scaleGradeList;
  332. this.$set(work, 'scaleGrade', scaleGradeList[0].label);
  333. if (work.scaleGrade == undefined) {
  334. this.$set(work, 'scaleGrade', '无');
  335. }
  336. if (work.groundType == undefined) {
  337. this.$set(work, 'groundType', '0');
  338. }
  339. this.getUnitPrice(work, work.workItem, work.subItem, work.scaleGrade, work.groundType);
  340. }
  341. })
  342. }
  343. },
  344. /* 获取单价 */
  345. getUnitPrice(work, workItem, subItem, scaleGrade, groundType) {
  346. getUnitPrice({ workItem, subItem, scaleGrade, groundType: groundType }).then(res => {
  347. if (res.length != 0) {
  348. work.checkPriceId = res.data.id;
  349. this.$set(work, 'price', res.data.price)
  350. this.$set(work, 'unit', res.data.unit)
  351. this.$set(work, 'coefficient', 1)
  352. this.$set(work, 'remark', res.data.remark)
  353. if (work.workload != undefined || work.workload != '') {
  354. this.getTotal(work);
  355. }
  356. }
  357. })
  358. },
  359. /* 获取总额 */
  360. getTotal(work) {
  361. let total = this.calculateTotal(work.price, work.coefficient, work.workload, 1);
  362. this.$set(work, 'settle', total)
  363. this.getSettleSum();
  364. },
  365. /* 计算总额 */
  366. calculateTotal(price, coefficient, workload, percent) {
  367. return ((parseFloat(price) * parseFloat(coefficient) * parseFloat(workload)) * percent).toFixed(2);
  368. },
  369. getSettleSum() {
  370. let sum = 0;
  371. for (let work of this.contentList) {
  372. sum = sum + Number(work.settle)
  373. }
  374. this.settle = sum.toFixed(2);
  375. let obj = {}
  376. obj.workList = this.contentList;
  377. obj.settle = this.settle;
  378. this.$emit('getSettle', obj);
  379. this.$emit('getWorkList', this.contentList)
  380. },
  381. getCoefficientRemark(workType) {
  382. getPriceRemarkByWorkType({ workType }).then(res => {
  383. if (res.code == 200) {
  384. if (workType != undefined)
  385. this.$notify({
  386. title: workType,
  387. dangerouslyUseHTMLString: true,
  388. message: res.msg,
  389. duration: 0
  390. });
  391. }
  392. })
  393. },
  394. addWorkList() {
  395. this.contentList.push({
  396. content: '',
  397. workType: '',
  398. workItem: '',
  399. scaleGrade: '',
  400. groundType: '0',
  401. price: '',
  402. unit: '',
  403. workload: '',
  404. coefficient: 1,
  405. settle: 0,
  406. workSelect: {
  407. // 项目列表
  408. projectList: [],
  409. // 工作类别列表
  410. workTypeList: [],
  411. // 工作项目
  412. workItemList: [],
  413. // 项目细项
  414. subItemList: [],
  415. // 比例尺
  416. scaleGradeList: [],
  417. workTypeLoading: true,
  418. workItemLoading: true,
  419. subItemLoading: true,
  420. scaleGradeLoading: true,
  421. }
  422. });
  423. },
  424. deletWorkItem(index) {
  425. let arr = this.contentList;
  426. if (index >= 0 && index < arr.length) {
  427. arr.splice(index, 1);
  428. }
  429. this.getSettleSum();
  430. },
  431. // 数组去重,并格式化为label、value形式
  432. setArray(arr) {
  433. if (arr != [] && arr != undefined) {
  434. let datalist = [...new Set(arr)];
  435. let list = [];
  436. for (let i of datalist) {
  437. let obj = new Object();
  438. obj.label = i;
  439. obj.value = i;
  440. list.push(obj);
  441. }
  442. return list;
  443. } else {
  444. return [];
  445. }
  446. },
  447. },
  448. }
  449. </script>
  450. <style lang="scss" scoped>
  451. .delete-btn {
  452. position: absolute;
  453. left: -30px;
  454. top: 50%;
  455. transform: translate(0, -50%);
  456. color: #F56C6C;
  457. cursor: pointer;
  458. i {
  459. font-size: 25px;
  460. }
  461. }
  462. table {
  463. width: 100%;
  464. /*居中*/
  465. // margin: 0 auto;
  466. /*边框*/
  467. /* border: 1px solid black; */
  468. text-align: center;
  469. border-collapse: collapse;
  470. border: 1px solid #DCDFE6;
  471. /*设置背景颜色*/
  472. /* background-color: #bfa; */
  473. td {
  474. padding: 1px;
  475. }
  476. .head {
  477. background-color: #e7f6f3;
  478. font-family: '微软雅黑';
  479. font-size: 18;
  480. font-weight: bold;
  481. }
  482. }
  483. </style>