weeklySubmit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <view style="width: 100vw;height:100vh;">
  3. <view style="height: calc(100% - 104rpx);">
  4. <view style="padding: 20rpx;background-color: #fff;">
  5. <u--form labelPosition="left" labelAlign="center" :model="content" ref="uForm"
  6. :labelStyle="{fontSize:'32rpx'}" labelWidth="120">
  7. <u-form-item label="周数:" borderBottom ref="item1">
  8. <view class="content">
  9. 第 {{content.periods}} 周
  10. </view>
  11. </u-form-item>
  12. <u-form-item label="提交人:" borderBottom ref="item1">
  13. <view class="content">
  14. {{content.createBy}}
  15. </view>
  16. </u-form-item>
  17. <u-form-item label="部门名称:" borderBottom ref="item1">
  18. <view class="content">
  19. <view>
  20. {{content.deptName}}
  21. </view>
  22. </view>
  23. </u-form-item>
  24. <u-divider textColor="#2979ff" lineColor="#a8c7fa" :dashed="true" text="周报事务信息"></u-divider>
  25. <!-- v-if="ywWeeklyItemList.length!=0" -->
  26. <view v-if="title=='周报新增'" class="">
  27. <uni-card v-for="(item, index) in ywWeeklyItemList" :key="index" style="height: 800rpx;"
  28. :style="{ backgroundColor: item.submitState == 0 ? '#fde2e2' : (item.submitState == 1 ||item.submitState==3)? '#e1f3d8' : 'white' }">
  29. <span
  30. style="font-size: 16px;padding-top: 15rpx;display: inline-block;color:black">事项{{index+1}}</span>
  31. <span v-if="showNo != 'no'">
  32. <u-button v-if="item.submitState == null" @click="delThis(item,index)" size="small"
  33. style="width: 150rpx;float:right;margin-top: 8rpx;margin-left: 10rpx;" type="error"
  34. text="删除"></u-button>
  35. <!-- <u-button style="float:right;margin-top: 8rpx;width: 150rpx;" v-if="
  36. item.supervistionId == null ||
  37. item.supervistionId == '' ||
  38. item.supervistionId == undefined
  39. " @click="addThing(item)" size="small" type="primary">快速填写</u-button> -->
  40. </span>
  41. <u-divider></u-divider>
  42. <view style="font-size: 28rpx;" class="">
  43. <view style="line-height: 80rpx;display: flex;" class="">
  44. <span style="width:200rpx;text-align: center;">事务名称:</span> <u--textarea height="50"
  45. style="width: 500rpx;" v-model="item.itemName" placeholder="请输入事务名称">
  46. </u--textarea>
  47. </view>
  48. <view style="line-height: 80rpx;display: flex;margin-top: 10rpx;" class="">
  49. <span style="width:200rpx;text-align: center;">本周推进情况:</span> <u--textarea
  50. v-model="item.weekPace" placeholder="请输入本周推进情况">
  51. </u--textarea>
  52. </view>
  53. <view style="line-height: 80rpx;display: flex;margin-top: 10rpx;" class="">
  54. <span style="width:200rpx;text-align: center;">下周计划:</span> <u--textarea
  55. v-model="item.weekNextPlan" placeholder="请输入下周计划"></u--textarea>
  56. </view>
  57. <view style="line-height: 80rpx;display: flex;margin-top: 10rpx;" class="">
  58. <span style="width:200rpx;text-align: center;">完成时限:</span> <uni-datetime-picker
  59. type="date" :clear-icon="false" v-model="item.doneTime"
  60. @maskClick="maskClick" />
  61. </view>
  62. </view>
  63. </uni-card>
  64. <view v-if="showNo != 'no'" style="display: flex;margin-top: 20rpx;" class="">
  65. <u-button @click="handleAddYwWeeklyItem" size="small"
  66. style="width: 200rpx;margin-top: 20rpx;" type="primary" text="添加事项"></u-button>
  67. <u-button @click="submitForm" size="small" style="width: 200rpx;margin-top: 20rpx;"
  68. type="primary" text="提交"></u-button>
  69. </view>
  70. </view>
  71. <view v-else class="">
  72. <uni-card v-for="(item, index) in ywWeeklyItemList" :key="index" style="height: 800rpx;"
  73. :style="{ backgroundColor:item.ywSupervisionItem==null?'white': item.ywSupervisionItem.submitState == 0 ? '#fde2e2' : (item.ywSupervisionItem.submitState == 1||item.ywSupervisionItem.submitState == 3) ? '#e1f3d8' : 'white' }">
  74. <span
  75. style="font-size: 16px;padding-top: 15rpx;display: inline-block;color:black">事项{{index+1}}</span>
  76. <span v-if="showNo != 'no'">
  77. <u-button v-if="item.submitState == null" @click="delThis(item,index)" size="small"
  78. style="width: 150rpx;float:right;margin-top: 8rpx;margin-left: 10rpx;" type="error"
  79. text="删除"></u-button>
  80. <!-- <u-button style="float:right;margin-top: 8rpx;width: 150rpx;" v-if="
  81. item.supervistionId == null ||
  82. item.supervistionId == '' ||
  83. item.supervistionId == undefined
  84. " @click="addThing(item)" size="small" type="primary">快速填写</u-button> -->
  85. </span>
  86. <u-divider></u-divider>
  87. <view style="font-size: 28rpx;" class="">
  88. <view style="line-height: 80rpx;display: flex;" class="">
  89. <span style="width:200rpx;text-align: center;">事务名称:</span> <u--textarea height="50"
  90. style="width: 500rpx;" v-model="item.itemName" placeholder="请输入事务名称">
  91. </u--textarea>
  92. </view>
  93. <view style="line-height: 80rpx;display: flex;margin-top: 10rpx;" class="">
  94. <span style="width:200rpx;text-align: center;">本周推进情况:</span> <u--textarea
  95. v-model="item.weekPace" placeholder="请输入本周推进情况">
  96. </u--textarea>
  97. </view>
  98. <view style="line-height: 80rpx;display: flex;margin-top: 10rpx;" class="">
  99. <span style="width:200rpx;text-align: center;">下周计划:</span> <u--textarea
  100. v-model="item.weekNextPlan" placeholder="请输入下周计划"></u--textarea>
  101. </view>
  102. <view style="line-height: 80rpx;display: flex;margin-top: 10rpx;" class="">
  103. <span style="width:200rpx;text-align: center;">完成时限:</span> <uni-datetime-picker
  104. type="date" :clear-icon="false" v-model="item.doneTime"
  105. @maskClick="maskClick" />
  106. </view>
  107. </view>
  108. </uni-card>
  109. <view v-if="showNo != 'no'" style="display: flex;margin-top: 20rpx;" class="">
  110. <u-button @click="handleAddYwWeeklyItem" size="small"
  111. style="width: 200rpx;margin-top: 20rpx;" type="primary" text="添加事项"></u-button>
  112. <u-button @click="submitForm" size="small" style="width: 200rpx;margin-top: 20rpx;"
  113. type="primary" text="提交"></u-button>
  114. </view>
  115. </view>
  116. <!-- <uni-table ref="myTable" style="margin-top: 20rpx;" :loading="loading" border stripe
  117. type="selection" emptyText="暂无更多数据" @selection-change="selectionChange">
  118. <uni-tr>
  119. <uni-th width="50" align="center">序号</uni-th>
  120. <uni-th width="150" align="center">事务名称</uni-th>
  121. <uni-th width="200" align="center">本周推进情况</uni-th>
  122. <uni-th width="170" align="center">下周计划</uni-th>
  123. <uni-th width="155" align="center">完成时限</uni-th>
  124. <uni-th width="120" align="center">督办事项</uni-th>
  125. </uni-tr>
  126. <uni-tr v-for="(item, index) in ywWeeklyItemList" :key="index">
  127. <uni-td align="center">{{ index+1 }}</uni-td>
  128. <uni-td align="center">
  129. <view class="name">
  130. <u--textarea v-model="item.itemName" placeholder="请输入事务名称" autoHeight border="none">
  131. </u--textarea>
  132. </view>
  133. </uni-td>
  134. <uni-td align="center">
  135. <u--textarea v-model="item.weekPace" placeholder="请输入本周推进情况" autoHeight border="none">
  136. </u--textarea>
  137. </uni-td>
  138. <uni-td align="center">
  139. <u--textarea v-model="item.weekNextPlan" placeholder="请输入下周计划" autoHeight border="none">
  140. </u--textarea>
  141. </uni-td>
  142. <uni-td align="center">
  143. <uni-datetime-picker type="date" :clear-icon="false" v-model="item.doneTime"
  144. @maskClick="maskClick" />
  145. </uni-td>
  146. <uni-td align="center">
  147. <view class="uni-group">
  148. <button style="margin-top: 10rpx;" v-if="
  149. item.supervistionId == null ||
  150. item.supervistionId == '' ||
  151. item.supervistionId == undefined
  152. " @click="addThing(item)" class="uni-button" size="mini" type="primary">快速填写</button>
  153. <view v-else class="">
  154. </view>
  155. </view>
  156. </uni-td>
  157. </uni-tr>
  158. </uni-table> -->
  159. </u--form>
  160. <uni-popup ref="popup" background-color="#fff">
  161. <view style="padding:20rpx;width:600rpx;min-height: 400rpx;" class="popup-content">
  162. <view style="align-items: center;text-align: center;font-size: 36rpx;" class="">
  163. 督办事项
  164. </view>
  165. <uni-table type="selection" ref="dbTable" style="margin-top: 20rpx;" :loading="loading" border
  166. stripe show-checkbox emptyText="暂无更多数据" @selection-change="handleSelectionChange1">
  167. <uni-tr>
  168. <uni-th width="50" align="center">序号</uni-th>
  169. <uni-th width="150" align="center">事务名称</uni-th>
  170. <uni-th width="150" align="center">完成时限</uni-th>
  171. </uni-tr>
  172. <uni-tr v-for="(item, index) in gridData" :key="index">
  173. <uni-td align="center">{{ index+1 }}</uni-td>
  174. <uni-td align="center">
  175. <view class="name">
  176. {{item.title}}
  177. </view>
  178. </uni-td>
  179. <uni-td align="center">
  180. <view class="name">
  181. {{item.doneTime}}
  182. </view>
  183. </uni-td>
  184. </uni-tr>
  185. </uni-table>
  186. <view style="display: flex;margin-top: 20rpx;" class="">
  187. <u-button @click="cancel" style="width: 200rpx;" text="取消"></u-button>
  188. <u-button @click="submitInfo" style="width: 200rpx;" type="primary" text="确认"></u-button>
  189. </view>
  190. </view>
  191. </uni-popup>
  192. </view>
  193. </view>
  194. <u-modal :show="showDel" :showCancelButton='true' @cancel="showDel=false"
  195. @confirm="handleDeleteYwWeeklyItem(indexDel)" title="提示" content='是否确认删除?'></u-modal>
  196. <!-- <u-button >打开</u-button> -->
  197. </view>
  198. </template>
  199. <script>
  200. import {
  201. getWeekInYear,
  202. getNowWeekList
  203. } from "@/utils/wjw.js"
  204. export default {
  205. data() {
  206. return {
  207. showNo: null,
  208. title: '',
  209. selectionValue: null,
  210. loading: false,
  211. showDel: false,
  212. gridData: [],
  213. rowValue: null,
  214. indexDel: null,
  215. dialogTableVisible: false,
  216. ywWeeklyItemList: [],
  217. checkedYwWeeklyItem: [],
  218. lastSelectedRow: null,
  219. content: {
  220. periods: getWeekInYear(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd')),
  221. deptName: uni.getStorageSync('userInfo').dept.deptName,
  222. createBy: uni.getStorageSync('userInfo').nickName,
  223. ywSupervisionItemList: []
  224. }
  225. }
  226. },
  227. onLoad(options) {
  228. this.title = options.title
  229. console.log(options)
  230. if (options.id != null && options.id != '' && options.id != undefined) {
  231. uni.$u.http.get('/offcial/weekly/' + options.id).then((res) => {
  232. console.log('res', res)
  233. this.content = res.data
  234. this.ywWeeklyItemList = []
  235. this.ywWeeklyItemList = this.content.ywWeeklyItemList;
  236. })
  237. }
  238. if (options.showNo != '' && options.showNo != null && options.showNo != undefined) {
  239. this.showNo = options.showNo
  240. console.log(this.showNo)
  241. }
  242. uni.setNavigationBarTitle({
  243. title: options.title
  244. })
  245. if (options.title == '周报新增') {
  246. this.addThing()
  247. }
  248. },
  249. methods: {
  250. delThis(item, index) {
  251. this.showDel = true
  252. this.indexDel = index
  253. },
  254. submitForm() {
  255. var sumflg = true
  256. this.ywWeeklyItemList.forEach((item) => {
  257. if (!sumflg) return; // 如果sumflg为false,直接返回
  258. if (
  259. item.weekPace == null ||
  260. item.weekPace == "" ||
  261. item.weekPace == undefined
  262. ) {
  263. uni.showToast({
  264. title: "督办事项“" + item.itemName + "”本周推进情况不能为空",
  265. icon: "none",
  266. mask: true,
  267. duration: 3000
  268. })
  269. sumflg = false;
  270. return;
  271. }
  272. if (
  273. item.weekNextPlan == null ||
  274. item.weekNextPlan == "" ||
  275. item.weekNextPlan == undefined
  276. ) {
  277. uni.showToast({
  278. title: "督办事项“" + item.itemName + "”下周计划不能为空",
  279. icon: "none",
  280. mask: true,
  281. duration: 3000
  282. })
  283. sumflg = false;
  284. return;
  285. }
  286. });
  287. if (sumflg) {
  288. if (this.content.id != null && this.content.id != undefined && this.content.id != '') {
  289. this.content.ywWeeklyItemList = this.ywWeeklyItemList;
  290. uni.showLoading({
  291. title: "提交中...",
  292. mask: true
  293. })
  294. uni.$u.http.put('/offcial/weekly', this.content).then((res) => {
  295. uni.hideLoading()
  296. uni.showToast({
  297. title: "修改成功",
  298. icon: "none",
  299. mask: true,
  300. duration: 3000
  301. })
  302. setTimeout(() => {
  303. uni.$emit('query', {
  304. a: 2
  305. })
  306. uni.navigateBack()
  307. }, 3000)
  308. }).catch(res => {
  309. uni.$emit('query', {
  310. a: 2
  311. })
  312. uni.hideLoading()
  313. uni.showToast({
  314. title: res.msg,
  315. icon: "none"
  316. })
  317. })
  318. } else {
  319. this.content.ywWeeklyItemList = this.ywWeeklyItemList;
  320. uni.showLoading({
  321. title: "提交中...",
  322. mask: true
  323. })
  324. uni.$u.http.post('/offcial/weekly', this.content).then((res) => {
  325. uni.hideLoading()
  326. uni.showToast({
  327. title: "提交成功",
  328. icon: "none",
  329. mask: true,
  330. duration: 3000
  331. })
  332. setTimeout(() => {
  333. uni.$emit('query', {
  334. a: 1
  335. })
  336. uni.navigateBack()
  337. }, 3000)
  338. }).catch(res => {
  339. uni.hideLoading()
  340. uni.$emit('query', {
  341. a: 1
  342. })
  343. uni.showToast({
  344. title: res.msg,
  345. icon: "none"
  346. })
  347. })
  348. }
  349. }
  350. },
  351. cancel() {
  352. this.$refs.popup.close()
  353. },
  354. submitInfo() {
  355. console.log(this.selectionValue)
  356. this.rowValue.itemName = this.selectionValue.title;
  357. this.rowValue.weekPace =
  358. this.selectionValue.ywSupervisionItemList[0].progress;
  359. this.rowValue.doneTime = this.selectionValue.doneTime;
  360. this.rowValue.supervistionId = this.selectionValue.id;
  361. this.$refs.popup.close()
  362. this.$refs.dbTable.clearSelection();
  363. },
  364. handleSelectionChange1(selection) {
  365. // this.selectionValue = selection;
  366. console.log('sel', selection)
  367. if (selection.detail.index.length > 1) {
  368. // 如果选择了多于一行,取消之前的选择
  369. this.$refs.dbTable.toggleRowSelection(this.lastSelectedRow, false);
  370. }
  371. if (selection.detail.index.length > 0) {
  372. // 更新最后选择的行
  373. this.lastSelectedRow = selection.detail.index[selection.detail.index.length - 1];
  374. }
  375. this.selectionValue = this.gridData[selection.detail.index[0]]
  376. console.log(this.selectionValue)
  377. },
  378. // 快速填写
  379. addThing(row) {
  380. this.ywWeeklyItemList = []
  381. this.rowValue = row;
  382. uni.$u.http.get(`/offcial/supervision/sel/myselfDb`, {
  383. params: {
  384. orderByColumn: "createTime",
  385. isAsc: "Desc"
  386. }
  387. }).then((res) => {
  388. console.log('res69', res)
  389. if (res.rows.length > 0) {
  390. // this.$refs.popup.open()
  391. // this.gridData = res.rows;
  392. for (let i = 0; i < res.rows.length; i++) {
  393. this.ywWeeklyItemList.push({
  394. itemName: res.rows[i].title,
  395. weekPace: res.rows[i].ywSupervisionItemList[0].progress,
  396. doneTime: res.rows[i].doneTime,
  397. submitState: res.rows[i].ywSupervisionItemList[0].submitState,
  398. supervistionId: res.rows[i].ywSupervisionItemList[0].id,
  399. });
  400. }
  401. } else {
  402. uni.showToast({
  403. title: "暂无可选督办事项,请手动填写",
  404. icon: "none",
  405. mask: true,
  406. duration: 3000
  407. })
  408. }
  409. });
  410. },
  411. handleDeleteYwWeeklyItem(index1) {
  412. console.log('item', index1)
  413. console.log('ywWeeklyItemList', this.ywWeeklyItemList)
  414. const ywWeeklyItems = this.ywWeeklyItemList;
  415. const checkedYwWeeklyItems = [index1]
  416. this.ywWeeklyItemList = ywWeeklyItems.filter(function(item, index) {
  417. return checkedYwWeeklyItems.indexOf(index) == -1;
  418. });
  419. this.showDel = false
  420. },
  421. selectionChange(selection) {
  422. console.log('selection', selection)
  423. this.checkedYwWeeklyItem = selection.detail.index.map((item) => item);
  424. console.log(this.checkedYwWeeklyItem)
  425. },
  426. handleAddYwWeeklyItem() {
  427. let obj = {};
  428. obj.itemName = "";
  429. obj.weekPace = "";
  430. obj.weekNextPlan = "";
  431. obj.doneTime = "";
  432. obj.isDb = "";
  433. obj.remark = "";
  434. this.ywWeeklyItemList.push(obj);
  435. console.log(this.ywWeeklyItemList)
  436. },
  437. maskClick(val) {
  438. }
  439. }
  440. }
  441. </script>
  442. <style>
  443. </style>