Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

templateTable.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <template>
  2. <div class="">
  3. <div class="filter-container">
  4. <el-button
  5. size="small"
  6. class="filter-item"
  7. style="float:right;"
  8. @click="handleCreate"
  9. type="primary"
  10. icon="el-icon-circle-plus-outline"
  11. >{{ $t("table.add") }}
  12. </el-button>
  13. </div>
  14. <el-table
  15. :row-style="{ color: '#303133' }"
  16. :header-cell-style="{
  17. backgroundColor: 'rgb(245, 247, 250)',
  18. color: '#606266'
  19. }"
  20. :key="tableKey"
  21. :data="list"
  22. v-loading="listLoading"
  23. border
  24. fit
  25. highlight-current-row
  26. style="width: 100%;min-height:500px;"
  27. >
  28. <!-- <el-table-column align="center" :label="$t('table.id')" width="65" @click="handleUpdate(scope.row)">
  29. <template slot-scope="scope">
  30. <span>{{scope.row.id}}</span>
  31. </template>
  32. </el-table-column> -->
  33. <el-table-column align="center" label="标题">
  34. <template slot-scope="scope">
  35. <!-- <span @click="handleUpdate(scope.row)">{{scope.row.name}}</span> -->
  36. <span>{{ scope.row.title }}</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column align="center" label="内容">
  40. <template slot-scope="scope">
  41. <span v-html="scope.row.content">{{ scope.row.content }}</span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column
  45. align="center"
  46. :label="$t('table.actions')"
  47. width="230"
  48. class-name="small-padding fixed-width"
  49. >
  50. <template slot-scope="scope">
  51. <el-tooltip class="item" effect="dark" content="编辑" placement="top">
  52. <el-button
  53. icon="el-icon-edit-outline"
  54. type="primary"
  55. size="small"
  56. @click="handleUpdate(scope.row)"
  57. ></el-button>
  58. </el-tooltip>
  59. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  60. <el-button
  61. icon="el-icon-delete"
  62. v-if="scope.row.status != 'deleted'"
  63. size="small"
  64. type="danger"
  65. @click="handleModifyStatus(scope.row, 'deleted')"
  66. >
  67. </el-button>
  68. </el-tooltip>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <!-- <div class="pagination-container">
  73. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="listQuery.page" :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
  74. </el-pagination>
  75. </div> -->
  76. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
  77. <el-form
  78. :rules="rules"
  79. ref="dataForm"
  80. :model="temp"
  81. label-position="right"
  82. label-width="70px"
  83. >
  84. <el-form-item label="标题" prop="title">
  85. <el-input
  86. v-model="temp.title"
  87. maxlength="100"
  88. placeholder="请输入标题"
  89. ></el-input>
  90. </el-form-item>
  91. <el-form-item label="内容" v-if="type == 'course_disease' || type == 'sick_history'">
  92. <keep-alive>
  93. <editor
  94. ref="editor"
  95. id="editor"
  96. style="width: 600px"
  97. v-bind:r_content="temp.content"
  98. >
  99. </editor>
  100. </keep-alive>
  101. </el-form-item>
  102. <el-form-item label="内容" prop="content" v-else>
  103. <el-input
  104. type="textarea"
  105. :autosize="{ minRows: 4, maxRows: 4 }"
  106. v-model="temp.content"
  107. placeholder="请输入内容"
  108. ></el-input>
  109. </el-form-item>
  110. <el-form-item :label="$t('data_config.remark')">
  111. <el-input
  112. type="textarea"
  113. :autosize="{ minRows: 4, maxRows: 4 }"
  114. placeholder="请输入备注"
  115. v-model="temp.remark"
  116. ></el-input>
  117. </el-form-item>
  118. </el-form>
  119. <div slot="footer" class="dialog-footer">
  120. <el-button @click="dialogFormVisible = false">{{
  121. $t("table.cancel")
  122. }}</el-button>
  123. <el-button
  124. v-if="dialogStatus == 'create'"
  125. type="primary"
  126. @click="createData"
  127. >{{ $t("table.confirm") }}</el-button
  128. >
  129. <el-button v-else type="primary" @click="updateData">{{
  130. $t("table.confirm")
  131. }}</el-button>
  132. </div>
  133. </el-dialog>
  134. <el-dialog title="Reading statistics" :visible.sync="dialogPvVisible">
  135. <el-table
  136. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  137. :data="pvData"
  138. border
  139. fit
  140. highlight-current-row
  141. style="width: 100%"
  142. >
  143. <el-table-column prop="key" label="Channel"></el-table-column>
  144. <el-table-column prop="pv" label="Pv"></el-table-column>
  145. </el-table>
  146. <span slot="footer" class="dialog-footer">
  147. <el-button type="primary" @click="dialogPvVisible = false">{{
  148. $t("table.confirm")
  149. }}</el-button>
  150. </span>
  151. </el-dialog>
  152. </div>
  153. </template>
  154. <script>
  155. import {
  156. createChildConfig,
  157. createConfig,
  158. deleteChildConfig,
  159. updateChildConfig,
  160. updateTemplate
  161. } from "@/api/data";
  162. import waves from "@/directive/waves"; // 水波纹指令
  163. import { parseTime } from "@/utils";
  164. import store from "@/store";
  165. import bus from "@/assets/eventBus";
  166. import Editor from "@/components/Editor";
  167. export default {
  168. name: "complexTable",
  169. directives: {
  170. waves
  171. },
  172. components: {
  173. Editor
  174. },
  175. props: {
  176. type: {
  177. type: String,
  178. default: "patient"
  179. }
  180. },
  181. beforeMount() {},
  182. data() {
  183. return {
  184. currentId: undefined,
  185. tableKey: 0,
  186. // list: null,
  187. total: null,
  188. listLoading: true,
  189. listQuery: {
  190. page: 1,
  191. limit: 20,
  192. importance: undefined,
  193. title: undefined,
  194. type: this.type,
  195. sort: "+id"
  196. },
  197. importanceOptions: [1, 2, 3],
  198. // calendarTypeOptions,
  199. sortOptions: [
  200. { label: "ID Ascending", key: "+id" },
  201. { label: "ID Descending", key: "-id" }
  202. ],
  203. statusOptions: ["published", "draft", "deleted"],
  204. showReviewer: false,
  205. temp: {
  206. id: undefined,
  207. parent_id: 0,
  208. module: this.type,
  209. org_id: 0,
  210. title: "",
  211. content: "",
  212. remark: ""
  213. },
  214. dialogFormVisible: false,
  215. dialogStatus: "",
  216. textMap: {
  217. update: "修改",
  218. create: "新增"
  219. },
  220. dialogPvVisible: false,
  221. pvData: [],
  222. rules: {
  223. title: [{ required: true, message: "请输入名称", trigger: "blur" }],
  224. content: [{ required: true, message: "请输入字段名", trigger: "blur" }]
  225. },
  226. downloadLoading: false
  227. };
  228. },
  229. // watch: {
  230. // 'temp.config_field':function(){
  231. // this.temp.config_field = this.temp.config_field.replace(/[^A-Za-z]/g,'');
  232. // }
  233. // },
  234. computed: {
  235. list: function() {
  236. // const list = store.getters.configlist[this.type]
  237. // this.total = list.length
  238. return store.getters.configlist[this.type];
  239. }
  240. },
  241. filters: {
  242. statusFilter(status) {
  243. const statusMap = {
  244. published: "success",
  245. draft: "info",
  246. deleted: "danger"
  247. };
  248. return statusMap[status];
  249. },
  250. typeFilter(type) {
  251. return calendarTypeKeyValue[type];
  252. }
  253. },
  254. created() {
  255. this.getList();
  256. },
  257. methods: {
  258. fieldChange: function(newValue) {
  259. this.temp.config_field = newValue.replace(/[^A-Za-z]/g, "");
  260. },
  261. handleRowChange(currentRow, oldCurrentRow) {
  262. if (currentRow != undefined) {
  263. this.currentId = currentRow.id;
  264. bus.$emit("parentChangeId", currentRow);
  265. }
  266. },
  267. getList() {
  268. this.listLoading = false;
  269. // setTimeout(() => {
  270. // this.listLoading = false
  271. // }, 1 * 1000)
  272. },
  273. handleFilter() {
  274. this.listQuery.page = 1;
  275. this.getList();
  276. },
  277. handleSizeChange(val) {
  278. this.listQuery.limit = val;
  279. this.getList();
  280. },
  281. handleCurrentChange(val) {
  282. this.listQuery.page = val;
  283. this.getList();
  284. },
  285. handleModifyStatus(row, status) {
  286. this.temp = Object.assign({}, row); // copy obj
  287. this.$confirm("此操作将永久删除该配置项, 是否继续?", "提示", {
  288. confirmButtonText: "确 定",
  289. cancelButtonText: "取 消",
  290. type: "warning"
  291. })
  292. .then(() => {
  293. const tempData = Object.assign({}, this.temp);
  294. console.log("templdatae232333233",tempData)
  295. deleteChildConfig(tempData).then(response => {
  296. if (!response.data) {
  297. // 由于mockjs 不支持自定义状态码只能这样hack
  298. reject("error");
  299. }
  300. if (response.data.state === 0) {
  301. this.$message.error(response.data.msg);
  302. }
  303. const result = response.data.data.dataconfig;
  304. store
  305. .dispatch("updateParentConfigList", [tempData, "delete"])
  306. .then(() => {
  307. next();
  308. });
  309. });
  310. this.$message({
  311. type: "success",
  312. message: "删除成功!"
  313. });
  314. })
  315. .catch(() => {
  316. this.$message({
  317. type: "info",
  318. message: "已取消删除"
  319. });
  320. });
  321. },
  322. resetTemp() {
  323. this.temp = {
  324. id: undefined,
  325. parent_id: 0,
  326. module: this.type,
  327. org_id: 0,
  328. title: "",
  329. content: "",
  330. remark: ""
  331. };
  332. },
  333. handleCreate() {
  334. this.resetTemp();
  335. this.dialogStatus = "create";
  336. this.dialogFormVisible = true;
  337. this.$nextTick(() => {
  338. this.$refs["dataForm"].clearValidate();
  339. });
  340. },
  341. createData() {
  342. this.$refs["dataForm"].validate(valid => {
  343. if (this.type == "course_disease" || this.type == "sick_history") {
  344. this.temp.content = this.$refs.editor.content;
  345. }
  346. if (valid) {
  347. console.log("tmpe233223322323",this.temp)
  348. createConfig(this.temp).then(response => {
  349. if (!response.data) {
  350. // 由于mockjs 不支持自定义状态码只能这样hack
  351. reject("error");
  352. }
  353. if (response.data.state === 0) {
  354. this.$message.error(response.data.msg);
  355. }
  356. const result = response.data.data.dataconfig;
  357. // 更新store
  358. store.dispatch("updateConfigList", result).then(() => {});
  359. this.dialogFormVisible = false;
  360. this.$message.success("创建成功");
  361. });
  362. }
  363. });
  364. },
  365. handleUpdate(row) {
  366. this.temp = Object.assign({}, row); // copy obj
  367. this.dialogStatus = "update";
  368. this.dialogFormVisible = true;
  369. this.$nextTick(() => {
  370. this.$refs["dataForm"].clearValidate();
  371. });
  372. },
  373. updateData() {
  374. this.$refs["dataForm"].validate(valid => {
  375. if (valid) {
  376. const tempData = Object.assign({}, this.temp);
  377. if (this.type == "course_disease") {
  378. tempData.content = this.$refs.editor.content;
  379. }
  380. updateTemplate(tempData).then(response => {
  381. if (!response.data) {
  382. // 由于mockjs 不支持自定义状态码只能这样hack
  383. reject("error");
  384. }
  385. if (response.data.state === 0) {
  386. this.$message.error(response.data.msg);
  387. }
  388. const result = response.data.data.dataconfig;
  389. store
  390. .dispatch("updateParentConfigList", [result, "update"])
  391. .then(() => {
  392. next();
  393. });
  394. this.dialogFormVisible = false;
  395. this.$message.success("更新成功");
  396. });
  397. }
  398. });
  399. },
  400. handleDelete(row) {
  401. this.$message.success("删除成功");
  402. const index = this.list.indexOf(row);
  403. this.list.splice(index, 1);
  404. },
  405. handleFetchPv(pv) {
  406. fetchPv(pv).then(response => {
  407. this.pvData = response.data.pvData;
  408. this.dialogPvVisible = true;
  409. });
  410. },
  411. handleDownload() {
  412. this.downloadLoading = true;
  413. import("@/vendor/Export2Excel").then(excel => {
  414. const tHeader = ["timestamp", "title", "type", "importance", "status"];
  415. const filterVal = [
  416. "timestamp",
  417. "title",
  418. "type",
  419. "importance",
  420. "status"
  421. ];
  422. const data = this.formatJson(filterVal, this.list);
  423. excel.export_json_to_excel({
  424. header: tHeader,
  425. data,
  426. filename: "table-list"
  427. });
  428. this.downloadLoading = false;
  429. });
  430. },
  431. formatJson(filterVal, jsonData) {
  432. return jsonData.map(v =>
  433. filterVal.map(j => {
  434. if (j === "timestamp") {
  435. return parseTime(v[j]);
  436. } else {
  437. return v[j];
  438. }
  439. })
  440. );
  441. }
  442. }
  443. };
  444. </script>
  445. <style>
  446. .el-table td,
  447. .el-table th.is-leaf,
  448. .el-table--border,
  449. .el-table--group {
  450. border-color: #d0d3da;
  451. }
  452. .el-table--border::after,
  453. .el-table--group::after,
  454. .el-table::before {
  455. background-color: #d0d3da;
  456. }
  457. </style>