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

tableson.vue 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. <template>
  2. <div class="">
  3. <div class="filter-container">
  4. <el-button
  5. style="float: right;"
  6. class="filter-item"
  7. size="small"
  8. :disabled="addState"
  9. @click="handleCreate"
  10. type="primary"
  11. icon="el-icon-circle-plus-outline"
  12. >{{ $t("table.add") }}</el-button
  13. >
  14. </div>
  15. <el-table
  16. :row-style="{ color: '#303133' }"
  17. :header-cell-style="{
  18. backgroundColor: 'rgb(245, 247, 250)',
  19. color: '#606266'
  20. }"
  21. :key="tableKey"
  22. :data="list"
  23. v-loading="listLoading"
  24. border
  25. fit
  26. highlight-current-row
  27. >
  28. <el-table-column align="center" label="名称">
  29. <template slot-scope="scope">
  30. <span @click="handleUpdate(scope.row)">{{ scope.row.name }}</span>
  31. </template>
  32. </el-table-column>
  33. <el-table-column
  34. align="center"
  35. :label="$t('table.actions')"
  36. width="230"
  37. class-name="small-padding fixed-width"
  38. >
  39. <template slot-scope="scope">
  40. <el-tooltip class="item" effect="dark" content="编辑" placement="top">
  41. <el-button
  42. icon="el-icon-edit-outline"
  43. type="primary"
  44. size="small"
  45. @click="handleUpdate(scope.row)"
  46. ></el-button>
  47. </el-tooltip>
  48. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  49. <el-button
  50. icon="el-icon-delete"
  51. v-if="scope.row.status != 'deleted'"
  52. size="small"
  53. type="danger"
  54. @click="handleModifyStatus(scope.row, 'deleted')"
  55. >
  56. </el-button>
  57. </el-tooltip>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
  62. <el-form
  63. :rules="rules"
  64. ref="dataForm"
  65. :model="temp"
  66. label-position="right"
  67. label-width="70px"
  68. >
  69. <el-row v-if="showType">
  70. <el-col :span="12">
  71. <el-form-item label="血管通路类型" label-width="150">
  72. <el-radio v-model="temp.field_type" label="1">内瘘</el-radio>
  73. <el-radio v-model="temp.field_type" label="2">导管</el-radio>
  74. </el-form-item>
  75. </el-col>
  76. </el-row>
  77. <el-row>
  78. <el-col :span="12">
  79. <el-form-item :label="$t('data_config.config_name')" prop="name">
  80. <el-input v-model="temp.name" placeholder="请输入名称"></el-input>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :span="12">
  84. <el-form-item label="排序" prop="order">
  85. <el-input
  86. type="age"
  87. v-model.number="temp.orders"
  88. placeholder="请输入排序值,数值越大,排序越靠前"
  89. ></el-input>
  90. </el-form-item>
  91. </el-col>
  92. </el-row>
  93. <el-form-item :label="$t('data_config.remark')">
  94. <el-input
  95. type="textarea"
  96. :autosize="{ minRows: 4, maxRows: 4 }"
  97. placeholder="请输入备注"
  98. v-model="temp.remark"
  99. >
  100. </el-input>
  101. </el-form-item>
  102. </el-form>
  103. <div slot="footer" class="dialog-footer">
  104. <el-button @click="dialogFormVisible = false">{{
  105. $t("table.cancel")
  106. }}</el-button>
  107. <el-button
  108. v-if="dialogStatus == 'create'"
  109. type="primary"
  110. @click="createData"
  111. >{{ $t("table.confirm") }}</el-button
  112. >
  113. <el-button v-else type="primary" @click="updateData">{{
  114. $t("table.confirm")
  115. }}</el-button>
  116. </div>
  117. </el-dialog>
  118. <el-dialog title="Reading statistics" :visible.sync="dialogPvVisible">
  119. <el-table
  120. :data="pvData"
  121. border
  122. fit
  123. highlight-current-row
  124. style="width: 100%"
  125. >
  126. <el-table-column prop="key" label="Channel"> </el-table-column>
  127. <el-table-column prop="pv" label="Pv"> </el-table-column>
  128. </el-table>
  129. <span slot="footer" class="dialog-footer">
  130. <el-button type="primary" @click="dialogPvVisible = false">{{
  131. $t("table.confirm")
  132. }}</el-button>
  133. </span>
  134. </el-dialog>
  135. </div>
  136. </template>
  137. <script>
  138. import {
  139. fetchList,
  140. fetchPv,
  141. createArticle,
  142. updateArticle
  143. } from "@/api/article";
  144. import waves from "@/directive/waves"; // 水波纹指令
  145. import { parseTime } from "@/utils";
  146. import store from "@/store";
  147. import bus from "@/assets/eventBus";
  148. import {
  149. createConfig,
  150. createChildConfig,
  151. updateChildConfig,
  152. deleteChildConfig
  153. } from "@/api/data";
  154. const calendarTypeOptions = [
  155. { key: "CN", display_name: "China" },
  156. { key: "US", display_name: "USA" },
  157. { key: "JP", display_name: "Japan" },
  158. { key: "EU", display_name: "Eurozone" }
  159. ];
  160. // arr to obj ,such as { CN : "China", US : "USA" }
  161. const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
  162. acc[cur.key] = cur.display_name;
  163. return acc;
  164. }, {});
  165. export default {
  166. name: "tableson",
  167. directives: {
  168. waves
  169. },
  170. props: {
  171. type: {
  172. type: String,
  173. default: "patient"
  174. }
  175. },
  176. data() {
  177. return {
  178. currentId: undefined,
  179. tableKey: 0,
  180. total: null,
  181. listLoading: false,
  182. listQuery: {
  183. page: 1,
  184. limit: 20,
  185. importance: undefined,
  186. title: undefined,
  187. type: this.type,
  188. sort: "+id"
  189. },
  190. importanceOptions: [1, 2, 3],
  191. calendarTypeOptions,
  192. sortOptions: [
  193. { label: "ID Ascending", key: "+id" },
  194. { label: "ID Descending", key: "-id" }
  195. ],
  196. statusOptions: ["published", "draft", "deleted"],
  197. showReviewer: false,
  198. temp: {
  199. id: undefined,
  200. parent_id: 0,
  201. module: this.type,
  202. org_id: 0,
  203. name: "",
  204. field_name: undefined,
  205. value: "",
  206. remark: "",
  207. orders: 0,
  208. field_type:""
  209. },
  210. dialogFormVisible: false,
  211. dialogStatus: "",
  212. textMap: {
  213. update: "编辑",
  214. create: "新增"
  215. },
  216. dialogPvVisible: false,
  217. pvData: [],
  218. rules: {
  219. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  220. order: [
  221. { type: "number", message: "排序必须为数字值", trigger: "blur" }
  222. ]
  223. // timestamp: [{ type: 'date', required: true, message: 'timestamp is required', trigger: 'change' }],
  224. // title: [{ required: true, message: 'title is required', trigger: 'blur' }]
  225. },
  226. downloadLoading: false,
  227. parentConfig: undefined,
  228. addState: true,
  229. showType:false,
  230. typeName:"",
  231. showName:""
  232. };
  233. },
  234. computed: {
  235. list: function() {
  236. if (this.parentConfig != undefined) {
  237. this.addState = false;
  238. const list = store.getters.configlist[this.parentConfig.module];
  239. for (var i = 0; i < list.length; i++) {
  240. if (list[i].id === this.parentConfig.id) {
  241. return list[i]["childs"];
  242. break;
  243. }
  244. }
  245. // return store.getters.configlist[this.parentConfig.module][this.parentConfig.index ]["childs"];
  246. }
  247. }
  248. },
  249. filters: {
  250. statusFilter(status) {
  251. const statusMap = {
  252. published: "success",
  253. draft: "info",
  254. deleted: "danger"
  255. };
  256. return statusMap[status];
  257. },
  258. typeFilter(type) {
  259. return calendarTypeKeyValue[type];
  260. }
  261. },
  262. created() {
  263. },
  264. mounted() {
  265. var _this = this;
  266. bus.$on("parentChangeId", function(parentData) {
  267. console.log("parentData",parentData)
  268. _this.showName = parentData.name
  269. console.log("22222",_this.showName)
  270. if(parentData.name == "血管通路" || parentData.name == "血管通路部位"){
  271. _this.showType = true
  272. }else{
  273. _this.showType = false
  274. }
  275. _this.parentConfig = parentData;
  276. // _this.list = parentData.childs
  277. _this.temp = {
  278. id: undefined,
  279. parent_id: parentData.id,
  280. module: parentData.module,
  281. org_id: parentData.org_id,
  282. name: "",
  283. field_name: undefined,
  284. value: "",
  285. remark: "",
  286. orders: "",
  287. field_type:parentData.field_type
  288. };
  289. });
  290. },
  291. methods: {
  292. handleRowChange(currentRow, oldCurrentRow) {
  293. this.currentId = currentRow.id;
  294. },
  295. handleFilter() {
  296. this.listQuery.page = 1;
  297. this.getList();
  298. },
  299. handleSizeChange(val) {
  300. this.listQuery.limit = val;
  301. this.getList();
  302. },
  303. handleCurrentChange(val) {
  304. this.listQuery.page = val;
  305. this.getList();
  306. },
  307. handleModifyStatus(row, status) {
  308. if (
  309. row.name == "无肝素" ||
  310. row.name == "普通肝素" ||
  311. row.name == "低分子钠" ||
  312. row.name == "低分子钙" ||
  313. row.name == "阿加曲班" ||
  314. row.name == "枸橼酸钠"
  315. ) {
  316. this.$message.error("关联字段不能删除");
  317. return false;
  318. }
  319. this.temp = Object.assign({}, row); // copy obj
  320. this.$confirm("此操作将永久删除该配置项, 是否继续?", "提示", {
  321. confirmButtonText: "确 定",
  322. cancelButtonText: "取 消",
  323. type: "warning"
  324. })
  325. .then(() => {
  326. const tempData = Object.assign({}, this.temp);
  327. deleteChildConfig(tempData).then(response => {
  328. if (!response.data) {
  329. // 由于mockjs 不支持自定义状态码只能这样hack
  330. reject("error");
  331. }
  332. if (response.data.state === 0) {
  333. this.$message.error(response.data.msg);
  334. }
  335. const result = response.data.data.dataconfig;
  336. store
  337. .dispatch("updateChildConfigList", [tempData, "delete"])
  338. .then(() => {
  339. next();
  340. });
  341. });
  342. this.$message({
  343. type: "success",
  344. message: "删除成功!"
  345. });
  346. })
  347. .catch(() => {
  348. this.$message({
  349. type: "info",
  350. message: "已取消删除"
  351. });
  352. });
  353. },
  354. resetTemp() {
  355. this.temp = {
  356. id: undefined,
  357. parent_id: this.parentConfig.id,
  358. module: this.parentConfig.module,
  359. org_id: this.parentConfig.org_id,
  360. name: "",
  361. field_name: undefined,
  362. value: "",
  363. remark: "",
  364. orders: 0,
  365. field_type:this.parentConfig.field_type
  366. };
  367. },
  368. handleCreate() {
  369. this.resetTemp();
  370. this.dialogStatus = "create";
  371. // for (let i = 0; i < this.list.length; i++) {
  372. // if (
  373. // this.list[i].name == "无肝素" ||
  374. // this.list[i].name == "普通肝素" ||
  375. // this.list[i].name == "低分子肝素钠" ||
  376. // this.list[i].name == "低分子肝素钙" ||
  377. // this.list[i].name == "阿加曲班" ||
  378. // this.list[i].name == "枸橼酸钠"
  379. // ) {
  380. // this.$message.error("该项暂不支持新增");
  381. // return false;
  382. // }
  383. // }
  384. this.dialogFormVisible = true;
  385. this.$nextTick(() => {
  386. this.$refs["dataForm"].clearValidate();
  387. });
  388. },
  389. createData() {
  390. this.$refs["dataForm"].validate(valid => {
  391. if (valid) {
  392. this.temp.field_type = parseInt(this.temp.field_type)
  393. console.log("2222",this.temp.field_name)
  394. createChildConfig(this.temp).then(response => {
  395. if (!response.data) {
  396. // 由于mockjs 不支持自定义状态码只能这样hack
  397. reject("error");
  398. }
  399. if (response.data.state === 0) {
  400. this.$message.error(response.data.msg);
  401. }
  402. const result = response.data.data.dataconfig;
  403. // this.list.unshift(tempval)
  404. // 更新store
  405. store.dispatch("updateChildConfigList", [result, "create"]).then(() => {});
  406. this.dialogFormVisible = false;
  407. this.$message.success("创建成功");
  408. });
  409. }
  410. });
  411. },
  412. handleUpdate(row) {
  413. console.log("3333333334",this.showType)
  414. console.log("rwo222222",row)
  415. console.log("showname,",this.showName)
  416. row.field_type = row.field_type.toString()
  417. if (
  418. row.name == "无肝素" ||
  419. row.name == "普通肝素" ||
  420. row.name == "低分子肝素钠" ||
  421. row.name == "低分子肝素钙" ||
  422. row.name == "阿加曲班" ||
  423. row.name == "枸橼酸钠"
  424. ) {
  425. this.$message.error("关联字段不能编辑");
  426. return false;
  427. }
  428. this.temp = Object.assign({}, row); // copy obj
  429. this.dialogStatus = "update";
  430. this.dialogFormVisible = true;
  431. this.$nextTick(() => {
  432. this.$refs["dataForm"].clearValidate();
  433. });
  434. },
  435. updateData() {
  436. this.$refs["dataForm"].validate(valid => {
  437. if (valid) {
  438. const tempData = Object.assign({}, this.temp);
  439. tempData.field_type = parseInt(tempData.field_type)
  440. console.log("tempData", tempData);
  441. updateChildConfig(tempData).then(response => {
  442. if (!response.data) {
  443. // 由于mockjs 不支持自定义状态码只能这样hack
  444. reject("error");
  445. }
  446. if (response.data.state === 0) {
  447. this.$message.error(response.data.msg);
  448. }
  449. const result = response.data.data.dataconfig;
  450. store
  451. .dispatch("updateChildConfigList", [result, "update"])
  452. .then(() => {});
  453. this.dialogFormVisible = false;
  454. this.$message.success("更新成功");
  455. });
  456. }
  457. });
  458. },
  459. handleDelete(row) {
  460. this.$message.success("删除成功");
  461. const index = this.list.indexOf(row);
  462. this.list.splice(index, 1);
  463. },
  464. handleFetchPv(pv) {
  465. fetchPv(pv).then(response => {
  466. this.pvData = response.data.pvData;
  467. this.dialogPvVisible = true;
  468. });
  469. },
  470. handleDownload() {
  471. this.downloadLoading = true;
  472. import("@/vendor/Export2Excel").then(excel => {
  473. const tHeader = ["timestamp", "title", "type", "importance", "status"];
  474. const filterVal = [
  475. "timestamp",
  476. "title",
  477. "type",
  478. "importance",
  479. "status"
  480. ];
  481. const data = this.formatJson(filterVal, this.list);
  482. excel.export_json_to_excel({
  483. header: tHeader,
  484. data,
  485. filename: "table-list"
  486. });
  487. this.downloadLoading = false;
  488. });
  489. },
  490. formatJson(filterVal, jsonData) {
  491. return jsonData.map(v =>
  492. filterVal.map(j => {
  493. if (j === "timestamp") {
  494. return parseTime(v[j]);
  495. } else {
  496. return v[j];
  497. }
  498. })
  499. );
  500. }
  501. }
  502. };
  503. </script>
  504. <style rel="stylesheet/css" lang="scss" scoped></style>
  505. <style>
  506. .el-table td,
  507. .el-table th.is-leaf,
  508. .el-table--border,
  509. .el-table--group {
  510. border-color: #d0d3da;
  511. }
  512. .el-table--border::after,
  513. .el-table--group::after,
  514. .el-table::before {
  515. background-color: #d0d3da;
  516. }
  517. </style>