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.

457 lines
14 KiB

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