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.

383 lines
12 KiB

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