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.

390 lines
12 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
  1. <template>
  2. <div class="box">
  3. <div style="width: 200%">
  4. <el-card class="elcard" style="border-radius: 15px">
  5. <div class="publiccss">项目默认结果</div>
  6. <el-row style="margin-top: 20px">
  7. <el-col :span="4">
  8. <el-input
  9. v-model="pages.Filter"
  10. @clear="getlist"
  11. clearable
  12. ></el-input>
  13. </el-col>
  14. <el-col :span="4">
  15. <el-button type="" style="margin-left: 5%;background:rgb(203,240,209);color:rgb(31, 148, 96)" @click="getlist"
  16. >查询</el-button
  17. >
  18. </el-col>
  19. </el-row>
  20. <el-table
  21. :data="tableData"
  22. style="width: 100%; height: 500px;margin-top:20px"
  23. row-key="id"
  24. class="el-table__body-wrapper tbody"
  25. @row-click="rowick"
  26. highlight-current-row
  27. >
  28. <el-table-column prop="id" label="编号" width="300">
  29. </el-table-column>
  30. <el-table-column prop="displayName" label="名称" width="">
  31. </el-table-column>
  32. <el-table-column prop="creatorName" label="创建者" width="">
  33. </el-table-column>
  34. <el-table-column prop="creationTime" label="创建时间" width="200">
  35. <template slot-scope="scope">
  36. {{ scope.row.creationTime | dateFormat }}
  37. </template>
  38. </el-table-column>
  39. <el-table-column prop="lastModifierName" label="修改者" width="">
  40. </el-table-column>
  41. <el-table-column
  42. prop="lastModificationTime"
  43. label="修改时间"
  44. width="200"
  45. >
  46. <template slot-scope="scope">
  47. {{ scope.row.lastModificationTime | dateFormat }}
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="操作">
  51. <template>
  52. <el-tag
  53. class="move"
  54. style="cursor: move; margin-left: 15px;background-color: rgb(245, 245, 245);border:none"
  55. draggable="true"
  56. >
  57. <i
  58. class="el-icon-d-caret"
  59. style="width: 1rem; height: 1rem;color: rgb(113, 113, 113)"
  60. ></i>
  61. </el-tag>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <!-- 新增或者编辑弹框 -->
  66. <el-dialog
  67. :title="title == 1 ? '新增' : '编辑'"
  68. :visible.sync="dialogVisible"
  69. width="75%"
  70. >
  71. <el-form ref="form" :model="form" label-width="80px">
  72. <el-row>
  73. <el-col :span="12">
  74. <el-form-item label="编号">
  75. <el-input
  76. v-model="form.id"
  77. style="width: 70%"
  78. disabled
  79. ></el-input>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="12">
  83. <el-form-item label="名称">
  84. <el-input
  85. ref="refinput"
  86. v-model="form.displayName"
  87. style="width: 65%"
  88. ></el-input>
  89. </el-form-item>
  90. </el-col>
  91. </el-row>
  92. <el-row>
  93. <el-divider></el-divider>
  94. <el-col :span="4" style="margin-left: 15px">
  95. <el-form-item label="创建者">
  96. <el-input v-model="form.creatorName" disabled></el-input>
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="6">
  100. <el-form-item label="创建时间">
  101. <el-input
  102. :value="form.creationTime | dateFormat"
  103. disabled
  104. style="width: 94%"
  105. ></el-input>
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="4" style="margin-left: 0%">
  109. <el-form-item label="修改者">
  110. <el-input v-model="form.lastModifierName" disabled></el-input>
  111. </el-form-item>
  112. </el-col>
  113. <el-col :span="7">
  114. <el-form-item label="修改时间">
  115. <el-input
  116. :value="form.lastModificationTime | dateFormat"
  117. disabled
  118. style="width: 76%"
  119. ></el-input>
  120. </el-form-item>
  121. </el-col>
  122. </el-row>
  123. </el-form>
  124. <span slot="footer" class="dialog-footer">
  125. <el-button @click="dialogVisible = false"> </el-button>
  126. <el-button type="primary" @click="addoredit" class="bulletcommit"> </el-button>
  127. </span>
  128. </el-dialog>
  129. </el-card>
  130. </div>
  131. <!-- 按钮区域 -->
  132. <div style="margin-left: 10px; margin-top: 7%">
  133. <el-button type="" @click="add" class="commonbutton">新增</el-button>
  134. <el-button
  135. type=""
  136. @click="editpopup"
  137. style="margin-left: 0; margin-top: 10px"
  138. class="commonbutton"
  139. >编辑</el-button
  140. >
  141. <div style="margin-top: 10px">
  142. <el-button type="" @click="delsrts" class="commonbutton">删除</el-button>
  143. </div>
  144. <div style="margin-top: 10px">
  145. <el-button type="" @click="topping" class="commonbutton">置顶</el-button>
  146. </div>
  147. <div style="margin-top: 10px">
  148. <el-button type="" @click="toppings" class="commonbutton">置底</el-button>
  149. </div>
  150. <div style="margin-top: 10px">
  151. <el-button type="" :disabled="isshow" @click="assertion" class="commonbutton"
  152. >确定</el-button
  153. >
  154. </div>
  155. <div style="margin-top: 10px">
  156. <el-button type="" :disabled="isshow" @click="cancellation" class="commonbutton"
  157. >取消</el-button
  158. >
  159. </div>
  160. </div>
  161. </div>
  162. </template>
  163. <script>
  164. import Sortable from "sortablejs";
  165. import {
  166. projectresultlist,
  167. projecresutid,
  168. addprojecreuitd,
  169. editprojectresult,
  170. deletepojectresult,
  171. projecrselttopbottom,
  172. projectrultsdeg,
  173. } from "../../request/systemapi";
  174. export default {
  175. data() {
  176. return {
  177. isshow: true,
  178. pages: {
  179. Filter: "",
  180. SkipCount: 0,
  181. MaxResultCount: 100,
  182. Sorting: "displayOrder desc",
  183. },
  184. tableData: [],
  185. dialogVisible: false,
  186. title: 1,
  187. initTableData: [],
  188. form: {
  189. displayName: "",
  190. },
  191. curRow:{}
  192. };
  193. },
  194. created() {
  195. // this.form.lastModificationTime=this.tableData[]
  196. this.getlist();
  197. },
  198. mounted() {
  199. this.rowDrop();
  200. },
  201. watch: {
  202. foremtime() {
  203. return;
  204. },
  205. },
  206. methods: {
  207. //取消排序
  208. cancellation() {
  209. this.$message.info("取消操作");
  210. this.isshow = true;
  211. this.getlist();
  212. },
  213. //确定拖拽
  214. assertion() {
  215. const result = [];
  216. this.tableData.forEach((item, index) => {
  217. // index 从0开始的, displayOrder从大到小排
  218. console.log(item.id);
  219. // const currentDisplayOrder = this.tableData.length -1
  220. const currentDisplayOrder = this.initTableData[index].displayOrder;
  221. if (item.displayOrder != currentDisplayOrder) {
  222. // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
  223. result.push({ id: item.id, displayOrder: currentDisplayOrder });
  224. }
  225. });
  226. projectrultsdeg({ itemList: result }).then((res) => {
  227. this.$message.success("操作成功");
  228. this.isshow = true;
  229. this.getlist();
  230. });
  231. },
  232. //初始化
  233. rowDrop() {
  234. this.$nextTick(() => {
  235. const tbody = document.querySelector(".el-table__body-wrapper tbody");
  236. const _this = this;
  237. Sortable.create(tbody, {
  238. handle: ".move",
  239. animation: 300,
  240. onEnd({ newIndex, oldIndex }) {
  241. _this.isshow = false;
  242. const currRow = _this.tableData.splice(oldIndex, 1)[0];
  243. _this.tableData.splice(newIndex, 0, currRow);
  244. _this.tableData.map((item, index) => {
  245. if (index == newIndex && index == oldIndex) {
  246. // console.log(item, "新数据");
  247. } else if (index == oldIndex) {
  248. } else if (index == newIndex) {
  249. }
  250. });
  251. console.log(_this.tableData.map((item) => item.displayOrder));
  252. },
  253. });
  254. });
  255. },
  256. //置低
  257. toppings() {
  258. this.form={...this.curRow}
  259. if (this.form.id == undefined) {
  260. this.$message.warning("请点击选择操作的数据");
  261. } else {
  262. projecrselttopbottom(this.form.id, 2).then((res) => {
  263. this.$message.success("操作成功");
  264. this.getlist();
  265. });
  266. }
  267. },
  268. //置顶
  269. topping() {
  270. this.form={...this.curRow}
  271. if (this.form.id == undefined) {
  272. this.$message.warning("请点击选择操作的数据");
  273. } else {
  274. projecrselttopbottom(this.form.id, 1).then((res) => {
  275. this.$message.success("操作成功");
  276. this.getlist();
  277. });
  278. }
  279. },
  280. //删除
  281. delsrts() {
  282. this.form={...this.curRow}
  283. if (this.form.id == undefined) {
  284. this.$message.warning("请选择删除的数据");
  285. } else {
  286. this.$confirm("是否确认删除,是否继续?", "提示", {
  287. confirmButtonText: "确定",
  288. cancelButtonText: "取消",
  289. type: "warning",
  290. })
  291. .then(() => {
  292. deletepojectresult(this.form.id).then((res) => {
  293. this.$message.success("删除成功");
  294. this.getlist();
  295. this.form = {};
  296. });
  297. })
  298. .catch(() => {});
  299. // deletepojectresult(this.form.id).then((res) => {
  300. // this.$message.success("删除成功");
  301. // this.form = {};
  302. // this.getlist();
  303. // });
  304. }
  305. },
  306. //编辑弹框
  307. editpopup() {
  308. this.form={...this.curRow}
  309. if (this.form.id == undefined) {
  310. this.$message.warning("请点击选择操作的数据");
  311. } else {
  312. this.dialogVisible = true;
  313. this.title = 2;
  314. projecresutid(this.form.id).then((res) => {
  315. console.log(res);
  316. this.form = res.data;
  317. // this.form.lastModificationTime={{res.data.lastModificationTime | a}}
  318. });
  319. }
  320. },
  321. //确定新增或者编辑
  322. addoredit() {
  323. if (this.form.displayName == undefined) {
  324. this.$message.warning("请输入名称");
  325. } else {
  326. if (this.title == 1) {
  327. addprojecreuitd({ displayName: this.form.displayName }).then(
  328. (res) => {
  329. this.$message.success("新增成功");
  330. this.getlist();
  331. this.dialogVisible = false;
  332. }
  333. );
  334. } else if (this.title == 2) {
  335. console.log(this.form.displayName);
  336. if (this.form.displayName == "") {
  337. this.$message.warning("请输入名称");
  338. } else {
  339. editprojectresult(this.form.id, {
  340. displayName: this.form.displayName,
  341. }).then((res) => {
  342. this.$message.success("修改成功");
  343. this.getlist();
  344. this.dialogVisible = false;
  345. });
  346. }
  347. }
  348. }
  349. },
  350. //新增弹框
  351. add() {
  352. this.title = 1;
  353. this.dialogVisible = true;
  354. this.form = {};
  355. this.$nextTick(()=>{
  356. this.$refs.refinput.focus()
  357. })
  358. },
  359. //点击列表通过id查询
  360. rowick(row) {
  361. projecresutid(row.id).then((res) => {
  362. // console.log(res);
  363. // this.form = res.data;
  364. this.curRow={...res.data}
  365. });
  366. console.log(row);
  367. },
  368. getlist() {
  369. projectresultlist(this.pages).then((res) => {
  370. this.initTableData = [...res.data.items];
  371. this.tableData = res.data.items;
  372. console.log(res);
  373. });
  374. },
  375. },
  376. };
  377. </script>
  378. <style scoped>
  379. ::v-deep .el-table__header th {
  380. /* font-size: px; */
  381. background-color: rgb(245, 245, 245); /* 设置表头背景颜色 */
  382. color: rgb(113, 113, 113); /* 设置表头文字颜色 */
  383. }
  384. ::v-deep .el-input.is-disabled .el-input__inner {
  385. width: 88%;
  386. }
  387. .box {
  388. display: flex;
  389. }
  390. </style>