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.

512 lines
16 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
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: 150%">
  4. <el-card class="elcard" style="border-radius: 15px">
  5. <div class="publiccss">项目结果模板</div>
  6. <el-table
  7. :data="tableData"
  8. style="width: 100%; margin-top: 20px"
  9. row-key="id"
  10. class="el-table__body-wrapper tbody"
  11. @row-click="rowclick"
  12. highlight-current-row
  13. >
  14. <el-table-column prop="id" label="编号" width="300">
  15. </el-table-column>
  16. <el-table-column prop="creatorName" label="创建者" width="">
  17. </el-table-column>
  18. <el-table-column prop="creationTime" label="创建时间" width="200">
  19. <template slot-scope="scope">
  20. {{ scope.row.creationTime | dateFormat }}
  21. </template>
  22. </el-table-column>
  23. <el-table-column prop="lastModifierName" label="修改者" width="">
  24. </el-table-column>
  25. <el-table-column
  26. prop="lastModificationTime"
  27. label="修改时间"
  28. width="200"
  29. >
  30. <template slot-scope="scope">
  31. {{ scope.row.lastModificationTime | dateFormat }}
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="result" label="结果" width="">
  35. </el-table-column>
  36. <el-table-column label="操作" width="">
  37. <template>
  38. <el-tag
  39. class="move"
  40. style="
  41. cursor: move;
  42. margin-left: 15px;
  43. background-color: rgb(245, 245, 245);
  44. border: none;
  45. "
  46. draggable="true"
  47. >
  48. <i
  49. class="el-icon-d-caret"
  50. style="width: 1rem; height: 1rem; color: rgb(113, 113, 113)"
  51. ></i>
  52. </el-tag>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <!-- <comp-table
  57. :tableData="tableData"
  58. :tableHeader="tableHeader"
  59. @clickevents="rowclick"
  60. ref="singleTable"
  61. >
  62. </comp-table> -->
  63. </el-card>
  64. <!-- 弹框 -->
  65. <el-dialog
  66. :title="title == 1 ? '新增' : '编辑'"
  67. :visible.sync="dialogVisible"
  68. width="75%"
  69. :close-on-click-modal="false"
  70. >
  71. <el-form ref="form" :model="form" label-width="80px" :rules="rules">
  72. <el-row>
  73. <el-col :span="8">
  74. <el-form-item label="项目" prop="itemId">
  75. <el-select
  76. filterable
  77. v-model="form.itemId"
  78. placeholder="请选择"
  79. >
  80. <el-option
  81. v-for="item in itemId"
  82. :key="item.id"
  83. :label="item.displayName"
  84. :value="item.id"
  85. >
  86. </el-option>
  87. </el-select>
  88. </el-form-item>
  89. </el-col>
  90. <el-col :span="8">
  91. <el-form-item label="结果" prop="result">
  92. <el-input v-model="form.result" style="width: 80%"></el-input>
  93. </el-form-item>
  94. </el-col>
  95. <el-col :span="8">
  96. <el-form-item label="诊断编号" prop="diagnosisId">
  97. <el-select
  98. filterable
  99. v-model="form.diagnosisId"
  100. placeholder="请选择"
  101. >
  102. <el-option
  103. v-for="item in diagnosisId"
  104. :key="item.id"
  105. :label="item.displayName"
  106. :value="item.id"
  107. >
  108. </el-option>
  109. </el-select>
  110. </el-form-item>
  111. </el-col>
  112. <el-col :span="8">
  113. <el-form-item label="小结名称" prop="isNameIntoSummary">
  114. <el-select
  115. filterable
  116. v-model="form.isNameIntoSummary"
  117. placeholder="请选择"
  118. >
  119. <el-option
  120. v-for="item in isNameIntoSummary"
  121. :key="item.value"
  122. :label="item.label"
  123. :value="item.value"
  124. >
  125. </el-option>
  126. </el-select>
  127. </el-form-item>
  128. </el-col>
  129. <el-col :span="8">
  130. <el-form-item label="进入小结" prop="isResultIntoSummary">
  131. <el-select
  132. filterable
  133. v-model="form.isResultIntoSummary"
  134. placeholder="请选择"
  135. >
  136. <el-option
  137. v-for="item in isResultIntoSummary"
  138. :key="item.value"
  139. :label="item.label"
  140. :value="item.value"
  141. >
  142. </el-option>
  143. </el-select>
  144. </el-form-item>
  145. </el-col>
  146. <el-col :span="8">
  147. <el-form-item label="结果状态" prop="resultStatusId">
  148. <el-select
  149. filterable
  150. v-model="form.resultStatusId"
  151. placeholder="请选择"
  152. >
  153. <el-option
  154. v-for="item in resultStatusId"
  155. :key="item.id"
  156. :label="item.displayName"
  157. :value="item.id"
  158. >
  159. </el-option>
  160. </el-select>
  161. </el-form-item>
  162. </el-col>
  163. <el-col :span="8">
  164. <el-form-item label="拼音简码" prop="simpleCode">
  165. <el-input
  166. v-model="form.simpleCode"
  167. style="width: 80%"
  168. ></el-input>
  169. </el-form-item>
  170. </el-col>
  171. </el-row>
  172. </el-form>
  173. <span slot="footer" class="dialog-footer">
  174. <el-button @click="dialogVisible = false"> </el-button>
  175. <el-button type="primary" @click="onsbmit"> </el-button>
  176. </span>
  177. </el-dialog>
  178. </div>
  179. <!-- 按钮区域 -->
  180. <div style="margin-left: 10px; margin-top: 5%" class="buttonarea">
  181. <el-button type="" @click="add" class="commonbutton">新增</el-button>
  182. <el-button
  183. type=""
  184. @click="editpopup"
  185. style="margin-left: 0; margin-top: 10px"
  186. class="commonbutton"
  187. >编辑</el-button
  188. >
  189. <div style="margin-top: 10px">
  190. <el-button type="" @click="delets" class="commonbutton">删除</el-button>
  191. </div>
  192. <div style="margin-top: 10px">
  193. <el-button type="" @click="topping" class="commonbutton"
  194. >置顶</el-button
  195. >
  196. </div>
  197. <div style="margin-top: 10px">
  198. <el-button type="" @click="toppings" class="commonbutton"
  199. >置底</el-button
  200. >
  201. </div>
  202. <div style="margin-top: 10px">
  203. <el-button
  204. type=""
  205. :disabled="isshow"
  206. @click="assertion"
  207. class="commonbutton"
  208. >排序</el-button
  209. >
  210. </div>
  211. <div style="margin-top: 5px">
  212. <el-button
  213. type=""
  214. :disabled="isshow"
  215. @click="cancellation"
  216. class="commonbutton"
  217. >取消</el-button
  218. >
  219. </div>
  220. </div>
  221. </div>
  222. </template>
  223. <script>
  224. import { rowDrop } from "@/components/publicjs/public";
  225. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  226. import { getporjectlists } from "@/request/commonapi";
  227. import compTable from "@/components/compTable.vue";
  228. import Sortable from "sortablejs";
  229. export default {
  230. components: { compTable },
  231. data() {
  232. return {
  233. isshow: true,
  234. rules: {
  235. itemId: [{ required: true, message: "请选择项目", trigger: "change" }],
  236. result: [{ required: true, message: "请输入结果", trigger: "blur" }],
  237. diagnosisId: [
  238. { required: true, message: "请选择诊断编号", trigger: "change" },
  239. ],
  240. isNameIntoSummary: [
  241. { required: true, message: "请选择小结名称", trigger: "change" },
  242. ],
  243. isResultIntoSummary: [
  244. { required: true, message: "请选择进入小结", trigger: "change" },
  245. ],
  246. resultStatusId: [
  247. { required: true, message: "请选择结果状态", trigger: "change" },
  248. ],
  249. simpleCode: [
  250. { required: true, message: "请输入拼音简码", trigger: "change" },
  251. ],
  252. },
  253. form: {
  254. itemId: "",
  255. result: "",
  256. diagnosisId: "",
  257. isNameIntoSummary: "",
  258. isResultIntoSummary: "",
  259. resultStatusId: "",
  260. simpleCode: "",
  261. },
  262. dialogVisible: false,
  263. title: 1,
  264. pages: {
  265. SkipCount: 0,
  266. MaxResultCount: 100,
  267. Sorting: "displayOrder desc",
  268. },
  269. itemId: [], //项目
  270. diagnosisId: [], //诊断
  271. resultStatusId: [], //结果状态 1
  272. isNameIntoSummary: [
  273. {
  274. value: "N",
  275. label: "否",
  276. },
  277. {
  278. value: "Y",
  279. label: "是",
  280. },
  281. ], // 小结名称
  282. isResultIntoSummary: [
  283. {
  284. value: "N",
  285. label: "否",
  286. },
  287. {
  288. value: "Y",
  289. label: "是",
  290. },
  291. ], //进入小结
  292. tableData: [],
  293. initTableData: [],
  294. tableHeader: [
  295. // 表头信息,可根据minWidth修改宽度
  296. { prop: "id", label: "编号", minWidth: "150px" },
  297. { prop: `creatorName`, label: "创建者" },
  298. { prop: `creationTime`, label: "创建时间" },
  299. { prop: `lastModifierName`, label: "修改者" },
  300. { prop: `lastModificationTime`, label: "创建时间" },
  301. { prop: "result", label: "结果" },
  302. // { prop: "simpleCode", label: "拼音简码" },
  303. ],
  304. curRow: {},
  305. };
  306. },
  307. created() {
  308. this.getlist();
  309. },
  310. mounted() {
  311. this.rowDrop();
  312. },
  313. methods: {
  314. //取消排序
  315. cancellation() {
  316. this.$message.info("取消操作");
  317. this.isshow = true;
  318. this.getlist();
  319. },
  320. //确定排序
  321. assertion() {
  322. const result = [];
  323. this.tableData.forEach((item, index) => {
  324. // index 从0开始的, 你的displayOrder从大到小排
  325. console.log(item.id);
  326. // const currentDisplayOrder = this.tableData.length -1
  327. const currentDisplayOrder = this.initTableData[index].displayOrder;
  328. if (item.displayOrder != currentDisplayOrder) {
  329. // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
  330. result.push({ id: item.id, displayOrder: currentDisplayOrder });
  331. }
  332. });
  333. putapi("/api/app/itemresulttemplate/updatesortmany", {
  334. itemList: result,
  335. }).then((res) => {
  336. this.$message.success("操作成功");
  337. this.isshow = true;
  338. this.getlist();
  339. });
  340. },
  341. //初始化
  342. rowDrop() {
  343. this.$nextTick(() => {
  344. const tbody = document.querySelector(".el-table__body-wrapper tbody");
  345. const _this = this;
  346. Sortable.create(tbody, {
  347. handle: ".move",
  348. animation: 300,
  349. onEnd({ newIndex, oldIndex }) {
  350. _this.isshow = false;
  351. const currRow = _this.tableData.splice(oldIndex, 1)[0];
  352. _this.tableData.splice(newIndex, 0, currRow);
  353. _this.tableData.map((item, index) => {
  354. if (index == newIndex && index == oldIndex) {
  355. // console.log(item, "新数据");
  356. } else if (index == oldIndex) {
  357. } else if (index == newIndex) {
  358. }
  359. });
  360. console.log(_this.tableData.map((item) => item.displayOrder));
  361. },
  362. });
  363. });
  364. },
  365. toppings() {
  366. this.form = { ...this.curRow };
  367. if (this.form.id == undefined) {
  368. this.$message.warning("请选择操作的数据");
  369. } else {
  370. putapi(
  371. `/api/app/itemresulttemplate/updatemanysort?id=${
  372. this.form.id
  373. }&SortType=${2}`
  374. ).then((res) => {
  375. this.$message.success("操作成功");
  376. this.getlist();
  377. });
  378. }
  379. },
  380. topping() {
  381. this.form = { ...this.curRow };
  382. if (this.form.id == undefined) {
  383. this.$message.warning("请选择操作的数据");
  384. } else {
  385. putapi(
  386. `/api/app/itemresulttemplate/updatemanysort?id=${
  387. this.form.id
  388. }&SortType=${1}`
  389. ).then((res) => {
  390. this.$message.success("操作成功");
  391. this.getlist();
  392. });
  393. }
  394. },
  395. //删除
  396. delets(row) {
  397. this.form = { ...this.curRow };
  398. if (this.form.id == undefined) {
  399. this.$message.warning("请选择删除的数据");
  400. } else {
  401. this.$confirm("是否确认删除,是否继续?", "提示", {
  402. confirmButtonText: "确定",
  403. cancelButtonText: "取消",
  404. type: "warning",
  405. })
  406. .then(() => {
  407. deletapi(`/api/app/item-result-template/${this.form.id}`).then(
  408. (res) => {
  409. if (res.code == 0) {
  410. this.$message.success("删除成功");
  411. this.getlist();
  412. }
  413. }
  414. );
  415. })
  416. .catch(() => {});
  417. }
  418. },
  419. //编辑弹框
  420. editpopup() {
  421. this.form = { ...this.curRow };
  422. if (this.form.id == undefined) {
  423. this.$message.warning("请点击选择操作的数据");
  424. } else {
  425. this.dialogVisible = true;
  426. this.title = 2;
  427. this.addtoedit();
  428. getapi(`/api/app/item-result-template/${this.form.id}`).then((res) => {
  429. console.log(res);
  430. });
  431. }
  432. },
  433. //确定新增或者编辑
  434. onsbmit() {
  435. this.$refs.form.validate((v) => {
  436. if (v) {
  437. if (this.title == 1) {
  438. postapi("/api/app/item-result-template", this.form).then((res) => {
  439. this.$message.success("新增成功");
  440. this.getlist();
  441. this.dialogVisible = false;
  442. });
  443. } else if (this.title == 2) {
  444. putapi(
  445. `/api/app/item-result-template/${this.form.id}`,
  446. this.form
  447. ).then((res) => {
  448. this.$message.success("修改成功");
  449. this.getlist();
  450. this.dialogVisible = false;
  451. });
  452. }
  453. }
  454. });
  455. },
  456. rowclick(val) {
  457. getapi(`/api/app/item-result-template/${val.id}`).then((res) => {
  458. // this.form = res.data;
  459. this.curRow = { ...res.data };
  460. console.log(res);
  461. });
  462. },
  463. handleRowClick(Row) {
  464. console.log(Row);
  465. console.log("1");
  466. },
  467. // 新增或者编辑需要的类别
  468. addtoedit() {
  469. //项目
  470. getporjectlists().then((res) => {
  471. this.itemId = res.data.items;
  472. });
  473. // 诊断
  474. postapi("/api/app/diagnosis/getlistinfilter").then((res) => {
  475. this.diagnosisId = res.data.items;
  476. });
  477. //结果状态
  478. getapi("/api/app/result-status").then((res) => {
  479. this.resultStatusId = res.data.items;
  480. });
  481. getapi("/api/app/diagnosis/getlistinfilter").then((res) => {});
  482. },
  483. //新增弹框
  484. add() {
  485. this.addtoedit();
  486. this.dialogVisible = true;
  487. this.title = 1;
  488. this.form = {};
  489. },
  490. getlist() {
  491. getapi("/api/app/item-result-template", this.pages).then((res) => {
  492. console.log(res);
  493. this.tableData = res.data.items;
  494. this.initTableData = [...res.data.items];
  495. });
  496. let that = this;
  497. },
  498. },
  499. };
  500. </script>
  501. <style scoped>
  502. ::v-deep .el-table__header th {
  503. /* font-size: px; */
  504. background-color: rgb(245, 245, 245); /* 设置表头背景颜色 */
  505. color: rgb(113, 113, 113); /* 设置表头文字颜色 */
  506. }
  507. .box {
  508. display: flex;
  509. }
  510. </style>