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.

409 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
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. height="500"
  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"
  55. draggable="true"
  56. >
  57. <i
  58. class="el-icon-d-caret"
  59. style="width: 1rem; height: 1rem"
  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="9">
  74. <el-form-item label="编号">
  75. <el-input
  76. v-model="form.id"
  77. style="width: 100%"
  78. disabled
  79. ></el-input>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="7">
  83. <el-form-item label="名称">
  84. <el-input
  85. v-model="form.displayName"
  86. maxlength="1"
  87. show-word-limit
  88. style="width: 90%"
  89. ></el-input>
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="7">
  93. 类别
  94. <el-select
  95. v-model="form.commonCharName"
  96. placeholder="请选择"
  97. @change="change"
  98. >
  99. <el-option
  100. v-for="item in ars"
  101. :key="item.id"
  102. :label="item.displayName"
  103. :value="item.id"
  104. >
  105. </el-option>
  106. </el-select>
  107. </el-col>
  108. </el-row>
  109. <el-row>
  110. <el-divider></el-divider>
  111. <el-col :span="4" style="margin-left: 15px">
  112. <el-form-item label="创建者">
  113. <el-input v-model="form.creatorName" disabled></el-input>
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="6">
  117. <el-form-item label="创建时间">
  118. <el-input
  119. :value="form.creatorName | dateFormat"
  120. disabled
  121. style="width: 95%"
  122. ></el-input>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :span="4">
  126. <el-form-item label="修改者">
  127. <el-input v-model="form.lastModifierName" disabled></el-input>
  128. </el-form-item>
  129. </el-col>
  130. <el-col :span="6">
  131. <el-form-item label="修改时间">
  132. <el-input
  133. :value="form.lastModificationTime | dateFormat"
  134. disabled
  135. style="width: 95%"
  136. ></el-input>
  137. </el-form-item>
  138. </el-col>
  139. </el-row>
  140. </el-form>
  141. <span slot="footer" class="dialog-footer">
  142. <el-button @click="dialogVisible = false"> </el-button>
  143. <el-button type="primary" @click="addoredit"> </el-button>
  144. </span>
  145. </el-dialog>
  146. </el-card>
  147. </div>
  148. <!-- 按钮区域 -->
  149. <div style="margin-left: 10px; margin-top: 10%">
  150. <el-button type="primary" @click="add">新增</el-button>
  151. <el-button
  152. type="primary"
  153. @click="editpopup"
  154. style="margin-left: 0; margin-top: 10px"
  155. >编辑</el-button
  156. >
  157. <div style="margin-top: 10px">
  158. <el-button type="danger" @click="delsrts">删除</el-button>
  159. </div>
  160. <div style="margin-top: 10px">
  161. <el-button type="primary" @click="topping">置顶</el-button>
  162. <div style="margin-top: 10px">
  163. <el-button type="primary" @click="toppings">置底</el-button>
  164. </div>
  165. <div style="margin-top: 10px">
  166. <el-button type="primary" :disabled="isshow" @click="assertion"
  167. >排序</el-button
  168. >
  169. </div>
  170. <div style="margin-top: 5px">
  171. <el-button type="primary" :disabled="isshow" @click="cancellation"
  172. >取消</el-button
  173. >
  174. </div>
  175. </div>
  176. </div>
  177. </div>
  178. </template>
  179. <script>
  180. import Sortable, { get } from "sortablejs";
  181. import {
  182. frequentlyusedlist,
  183. categorytype,
  184. addingwordes,
  185. commonid,
  186. commoneditors,
  187. usedtopping,
  188. sortcommonwords,
  189. commondelt,
  190. } from "../../request/systemapi";
  191. import { getapi } from "@/api/api";
  192. export default {
  193. data() {
  194. return {
  195. pages: {
  196. Filter: "",
  197. SkipCount: 0,
  198. MaxResultCount: 100,
  199. Sorting: "displayOrder desc",
  200. },
  201. form: {
  202. displayName: "",
  203. ars: "",
  204. },
  205. ars: [],
  206. tableData: [],
  207. value: "",
  208. title: 1,
  209. dialogVisible: false,
  210. isshow: true,
  211. };
  212. },
  213. created() {
  214. this.getlist();
  215. },
  216. mounted() {
  217. this.rowDrop();
  218. },
  219. methods: {
  220. //删除
  221. delsrts() {
  222. if (this.form.id == undefined) {
  223. this.$message.warning("请选择删除的数据");
  224. } else {
  225. this.$confirm("是否确认删除,是否继续?", "提示", {
  226. confirmButtonText: "确定",
  227. cancelButtonText: "取消",
  228. type: "warning",
  229. })
  230. .then(() => {
  231. commondelt(this.form.id).then((res) => {
  232. this.$message.success("删除成功");
  233. this.getlist();
  234. this.form = {};
  235. });
  236. })
  237. .catch(() => {});
  238. // commondelt(this.form.id).then((res) => {
  239. // this.$message.success("删除成功");
  240. // this.form = {};
  241. // this.getlist();
  242. // });
  243. }
  244. },
  245. change(v) {
  246. this.form.ids = v;
  247. console.log(v);
  248. },
  249. //取消排序
  250. cancellation() {
  251. this.$message.info("取消操作");
  252. this.isshow = true;
  253. this.getlist();
  254. },
  255. //确定拖拽
  256. assertion() {
  257. const result = [];
  258. this.tableData.forEach((item, index) => {
  259. // index 从0开始的, displayOrder从大到小排
  260. console.log(item.id);
  261. // const currentDisplayOrder = this.tableData.length -1
  262. const currentDisplayOrder = this.initTableData[index].displayOrder;
  263. if (item.displayOrder != currentDisplayOrder) {
  264. // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
  265. result.push({ id: item.id, displayOrder: currentDisplayOrder });
  266. }
  267. });
  268. sortcommonwords({ itemList: result }).then((res) => {
  269. this.$message.success("操作成功");
  270. this.isshow = true;
  271. this.getlist();
  272. });
  273. },
  274. //初始化
  275. rowDrop() {
  276. this.$nextTick(() => {
  277. const tbody = document.querySelector(".el-table__body-wrapper tbody");
  278. const _this = this;
  279. Sortable.create(tbody, {
  280. handle: ".move",
  281. animation: 300,
  282. onEnd({ newIndex, oldIndex }) {
  283. _this.isshow = false;
  284. const currRow = _this.tableData.splice(oldIndex, 1)[0];
  285. _this.tableData.splice(newIndex, 0, currRow);
  286. _this.tableData.map((item, index) => {
  287. if (index == newIndex && index == oldIndex) {
  288. // console.log(item, "新数据");
  289. } else if (index == oldIndex) {
  290. } else if (index == newIndex) {
  291. }
  292. });
  293. console.log(_this.tableData.map((item) => item.displayOrder));
  294. },
  295. });
  296. });
  297. },
  298. //置低
  299. toppings() {
  300. if (this.form.id == undefined) {
  301. this.$message.warning("请点击选择操作的数据");
  302. } else {
  303. usedtopping(this.form.id, 2).then((res) => {
  304. this.$message.success("操作成功");
  305. this.getlist();
  306. });
  307. }
  308. },
  309. //置顶
  310. topping() {
  311. console.log(this.form.id);
  312. if (this.form.id == undefined) {
  313. this.$message.warning("请点击选择操作的数据");
  314. } else {
  315. usedtopping(this.form.id, 1).then((res) => {
  316. this.$message.success("操作成功");
  317. this.getlist();
  318. });
  319. }
  320. },
  321. //编辑弹框
  322. editpopup() {
  323. console.log(this.form.id);
  324. if (this.form.id == undefined) {
  325. this.$message.success("请点击选择操作的数据");
  326. } else {
  327. this.dialogVisible = true;
  328. this.title = 2;
  329. categorytype(this.pages).then((res) => {
  330. this.ars = res.data.items;
  331. console.log(res);
  332. });
  333. // console.log(this.tableData[0].id);
  334. commonid(this.form.id).then((res) => {
  335. this.form = res.data;
  336. });
  337. }
  338. },
  339. //确定新增或者编辑
  340. addoredit() {
  341. console.log(this.form.ids);
  342. if (this.form.displayName == undefined) {
  343. this.$message.warning("请输入名称");
  344. } else if (this.form.ars == "") {
  345. this.$message.warning("请选择项目"); //测试时校验选择项目不为空
  346. } else {
  347. if (this.title == 1) {
  348. addingwordes({
  349. displayName: this.form.displayName,
  350. commonCharTypeId: this.form.ids,
  351. }).then((res) => {
  352. this.$message.success("新增成功");
  353. this.getlist();
  354. this.dialogVisible = false;
  355. this.form = {};
  356. });
  357. } else if (this.title == 2) {
  358. commoneditors(this.form.id, {
  359. displayName: this.form.displayName,
  360. commonCharTypeId: this.form.ids,
  361. }).then((res) => {
  362. this.$message.success("修改成功");
  363. this.getlist();
  364. this.dialogVisible = false;
  365. });
  366. }
  367. }
  368. },
  369. //新增弹框
  370. add() {
  371. this.title = 1;
  372. this.dialogVisible = true;
  373. this.form = {};
  374. categorytype(this.pages).then((res) => {
  375. this.ars = res.data.items;
  376. console.log(res);
  377. });
  378. },
  379. getlist() {
  380. frequentlyusedlist(this.pages).then((res) => {
  381. this.initTableData = [...res.data.items];
  382. this.tableData = res.data.items;
  383. console.log(res);
  384. });
  385. },
  386. //点击列表通过id查询
  387. rowick(row) {
  388. commonid(row.id).then((res) => {
  389. console.log(res);
  390. this.form = res.data;
  391. });
  392. // //获取类别
  393. // getapi("/api/app/common-char-type/in-filter").then((res) => {
  394. // console.log(res, "类别");
  395. // this.ars = res.data.items;
  396. // });
  397. console.log(row);
  398. },
  399. },
  400. };
  401. </script>
  402. <style scoped>
  403. ::v-deep .el-input.is-disabled .el-input__inner {
  404. width: 88%;
  405. }
  406. .box {
  407. display: flex;
  408. }
  409. </style>