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.

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