123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541 |
- <template>
- <div class="">
- <div class="filter-container">
- <el-button
- style="float: right;"
- class="filter-item"
- size="small"
- :disabled="addState"
- @click="handleCreate"
- type="primary"
- icon="el-icon-circle-plus-outline"
- >{{ $t("table.add") }}</el-button
- >
- </div>
- <el-table
- :row-style="{ color: '#303133' }"
- :header-cell-style="{
- backgroundColor: 'rgb(245, 247, 250)',
- color: '#606266'
- }"
- :key="tableKey"
- :data="list"
- v-loading="listLoading"
- border
- fit
- highlight-current-row
- >
- <el-table-column align="center" label="名称">
- <template slot-scope="scope">
- <span @click="handleUpdate(scope.row)">{{ scope.row.name }}</span>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- :label="$t('table.actions')"
- width="230"
- class-name="small-padding fixed-width"
- >
- <template slot-scope="scope">
- <el-tooltip class="item" effect="dark" content="编辑" placement="top">
- <el-button
- icon="el-icon-edit-outline"
- type="primary"
- size="small"
- @click="handleUpdate(scope.row)"
- ></el-button>
- </el-tooltip>
-
- <el-tooltip class="item" effect="dark" content="删除" placement="top">
- <el-button
- icon="el-icon-delete"
- v-if="scope.row.status != 'deleted'"
- size="small"
- type="danger"
- @click="handleModifyStatus(scope.row, 'deleted')"
- >
- </el-button>
- </el-tooltip>
- </template>
- </el-table-column>
- </el-table>
-
- <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
- <el-form
- :rules="rules"
- ref="dataForm"
- :model="temp"
- label-position="right"
- label-width="70px"
- >
- <el-row v-if="showType">
- <el-col :span="12">
- <el-form-item label="血管通路类型" label-width="150">
- <el-radio v-model="temp.field_type" label="1">内瘘</el-radio>
- <el-radio v-model="temp.field_type" label="2">导管</el-radio>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item :label="$t('data_config.config_name')" prop="name">
- <el-input v-model="temp.name" placeholder="请输入名称"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="排序" prop="order">
- <el-input
- type="age"
- v-model.number="temp.orders"
- placeholder="请输入排序值,数值越大,排序越靠前"
- ></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item :label="$t('data_config.remark')">
- <el-input
- type="textarea"
- :autosize="{ minRows: 4, maxRows: 4 }"
- placeholder="请输入备注"
- v-model="temp.remark"
- >
- </el-input>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dialogFormVisible = false">{{
- $t("table.cancel")
- }}</el-button>
- <el-button
- v-if="dialogStatus == 'create'"
- type="primary"
- @click="createData"
- >{{ $t("table.confirm") }}</el-button
- >
- <el-button v-else type="primary" @click="updateData">{{
- $t("table.confirm")
- }}</el-button>
- </div>
- </el-dialog>
-
- <el-dialog title="Reading statistics" :visible.sync="dialogPvVisible">
- <el-table
- :data="pvData"
- border
- fit
- highlight-current-row
- style="width: 100%"
- >
- <el-table-column prop="key" label="Channel"> </el-table-column>
- <el-table-column prop="pv" label="Pv"> </el-table-column>
- </el-table>
- <span slot="footer" class="dialog-footer">
- <el-button type="primary" @click="dialogPvVisible = false">{{
- $t("table.confirm")
- }}</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
-
- <script>
- import {
- fetchList,
- fetchPv,
- createArticle,
- updateArticle
- } from "@/api/article";
- import waves from "@/directive/waves"; // 水波纹指令
- import { parseTime } from "@/utils";
- import store from "@/store";
- import bus from "@/assets/eventBus";
- import {
- createConfig,
- createChildConfig,
- updateChildConfig,
- deleteChildConfig
- } from "@/api/data";
-
- const calendarTypeOptions = [
- { key: "CN", display_name: "China" },
- { key: "US", display_name: "USA" },
- { key: "JP", display_name: "Japan" },
- { key: "EU", display_name: "Eurozone" }
- ];
-
- // arr to obj ,such as { CN : "China", US : "USA" }
- const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
- acc[cur.key] = cur.display_name;
- return acc;
- }, {});
-
- export default {
- name: "tableson",
- directives: {
- waves
- },
- props: {
- type: {
- type: String,
- default: "patient"
- }
- },
- data() {
- return {
- currentId: undefined,
- tableKey: 0,
- total: null,
- listLoading: false,
- listQuery: {
- page: 1,
- limit: 20,
- importance: undefined,
- title: undefined,
- type: this.type,
- sort: "+id"
- },
- importanceOptions: [1, 2, 3],
- calendarTypeOptions,
- sortOptions: [
- { label: "ID Ascending", key: "+id" },
- { label: "ID Descending", key: "-id" }
- ],
- statusOptions: ["published", "draft", "deleted"],
- showReviewer: false,
- temp: {
- id: undefined,
- parent_id: 0,
- module: this.type,
- org_id: 0,
- name: "",
- field_name: undefined,
- value: "",
- remark: "",
- orders: 0,
- field_type:""
- },
- dialogFormVisible: false,
- dialogStatus: "",
- textMap: {
- update: "编辑",
- create: "新增"
- },
- dialogPvVisible: false,
- pvData: [],
- rules: {
- name: [{ required: true, message: "请输入名称", trigger: "blur" }],
- order: [
- { type: "number", message: "排序必须为数字值", trigger: "blur" }
- ]
- // timestamp: [{ type: 'date', required: true, message: 'timestamp is required', trigger: 'change' }],
- // title: [{ required: true, message: 'title is required', trigger: 'blur' }]
- },
- downloadLoading: false,
- parentConfig: undefined,
- addState: true,
- showType:false,
- typeName:"",
- showName:""
- };
- },
- computed: {
- list: function() {
- if (this.parentConfig != undefined) {
- this.addState = false;
- const list = store.getters.configlist[this.parentConfig.module];
- for (var i = 0; i < list.length; i++) {
- if (list[i].id === this.parentConfig.id) {
- return list[i]["childs"];
- break;
- }
- }
- // return store.getters.configlist[this.parentConfig.module][this.parentConfig.index ]["childs"];
- }
- }
- },
- filters: {
- statusFilter(status) {
- const statusMap = {
- published: "success",
- draft: "info",
- deleted: "danger"
- };
- return statusMap[status];
- },
- typeFilter(type) {
- return calendarTypeKeyValue[type];
- }
- },
- created() {
-
- },
- mounted() {
- var _this = this;
- bus.$on("parentChangeId", function(parentData) {
- console.log("parentData",parentData)
- _this.showName = parentData.name
- console.log("22222",_this.showName)
- if(parentData.name == "血管通路" || parentData.name == "血管通路部位"){
-
- _this.showType = true
-
- }else{
- _this.showType = false
- }
- _this.parentConfig = parentData;
- // _this.list = parentData.childs
- _this.temp = {
- id: undefined,
- parent_id: parentData.id,
- module: parentData.module,
- org_id: parentData.org_id,
- name: "",
- field_name: undefined,
- value: "",
- remark: "",
- orders: "",
- field_type:parentData.field_type
- };
- });
- },
- methods: {
- handleRowChange(currentRow, oldCurrentRow) {
- this.currentId = currentRow.id;
- },
-
- handleFilter() {
- this.listQuery.page = 1;
- this.getList();
- },
- handleSizeChange(val) {
- this.listQuery.limit = val;
- this.getList();
- },
- handleCurrentChange(val) {
- this.listQuery.page = val;
- this.getList();
- },
- handleModifyStatus(row, status) {
- if (
- row.name == "无肝素" ||
- row.name == "普通肝素" ||
- row.name == "低分子钠" ||
- row.name == "低分子钙" ||
- row.name == "阿加曲班" ||
- row.name == "枸橼酸钠"
- ) {
- this.$message.error("关联字段不能删除");
- return false;
- }
- this.temp = Object.assign({}, row); // copy obj
- this.$confirm("此操作将永久删除该配置项, 是否继续?", "提示", {
- confirmButtonText: "确 定",
- cancelButtonText: "取 消",
- type: "warning"
- })
- .then(() => {
- const tempData = Object.assign({}, this.temp);
- deleteChildConfig(tempData).then(response => {
- if (!response.data) {
- // 由于mockjs 不支持自定义状态码只能这样hack
- reject("error");
- }
- if (response.data.state === 0) {
- this.$message.error(response.data.msg);
- }
-
- const result = response.data.data.dataconfig;
- store
- .dispatch("updateChildConfigList", [tempData, "delete"])
- .then(() => {
- next();
- });
- });
-
- this.$message({
- type: "success",
- message: "删除成功!"
- });
- })
- .catch(() => {
- this.$message({
- type: "info",
- message: "已取消删除"
- });
- });
- },
- resetTemp() {
- this.temp = {
- id: undefined,
- parent_id: this.parentConfig.id,
- module: this.parentConfig.module,
- org_id: this.parentConfig.org_id,
- name: "",
- field_name: undefined,
- value: "",
- remark: "",
- orders: 0,
- field_type:this.parentConfig.field_type
- };
- },
- handleCreate() {
- this.resetTemp();
- this.dialogStatus = "create";
- // for (let i = 0; i < this.list.length; i++) {
- // if (
- // this.list[i].name == "无肝素" ||
- // this.list[i].name == "普通肝素" ||
- // this.list[i].name == "低分子肝素钠" ||
- // this.list[i].name == "低分子肝素钙" ||
- // this.list[i].name == "阿加曲班" ||
- // this.list[i].name == "枸橼酸钠"
- // ) {
- // this.$message.error("该项暂不支持新增");
- // return false;
- // }
- // }
-
- this.dialogFormVisible = true;
- this.$nextTick(() => {
- this.$refs["dataForm"].clearValidate();
- });
- },
- createData() {
-
- this.$refs["dataForm"].validate(valid => {
- if (valid) {
- this.temp.field_type = parseInt(this.temp.field_type)
-
- console.log("2222",this.temp.field_name)
- createChildConfig(this.temp).then(response => {
- if (!response.data) {
- // 由于mockjs 不支持自定义状态码只能这样hack
- reject("error");
- }
- if (response.data.state === 0) {
- this.$message.error(response.data.msg);
- }
- const result = response.data.data.dataconfig;
-
- // this.list.unshift(tempval)
- // 更新store
- store.dispatch("updateChildConfigList", [result, "create"]).then(() => {});
- this.dialogFormVisible = false;
- this.$message.success("创建成功");
- });
- }
- });
- },
- handleUpdate(row) {
- console.log("3333333334",this.showType)
- console.log("rwo222222",row)
- console.log("showname,",this.showName)
- row.field_type = row.field_type.toString()
-
- if (
- row.name == "无肝素" ||
- row.name == "普通肝素" ||
- row.name == "低分子肝素钠" ||
- row.name == "低分子肝素钙" ||
- row.name == "阿加曲班" ||
- row.name == "枸橼酸钠"
- ) {
- this.$message.error("关联字段不能编辑");
- return false;
- }
-
- this.temp = Object.assign({}, row); // copy obj
- this.dialogStatus = "update";
- this.dialogFormVisible = true;
- this.$nextTick(() => {
- this.$refs["dataForm"].clearValidate();
- });
- },
- updateData() {
- this.$refs["dataForm"].validate(valid => {
- if (valid) {
- const tempData = Object.assign({}, this.temp);
- tempData.field_type = parseInt(tempData.field_type)
- console.log("tempData", tempData);
- updateChildConfig(tempData).then(response => {
- if (!response.data) {
- // 由于mockjs 不支持自定义状态码只能这样hack
- reject("error");
- }
- if (response.data.state === 0) {
- this.$message.error(response.data.msg);
- }
-
- const result = response.data.data.dataconfig;
- store
- .dispatch("updateChildConfigList", [result, "update"])
- .then(() => {});
-
- this.dialogFormVisible = false;
-
- this.$message.success("更新成功");
- });
- }
- });
- },
- handleDelete(row) {
- this.$message.success("删除成功");
- const index = this.list.indexOf(row);
- this.list.splice(index, 1);
- },
- handleFetchPv(pv) {
- fetchPv(pv).then(response => {
- this.pvData = response.data.pvData;
- this.dialogPvVisible = true;
- });
- },
- handleDownload() {
- this.downloadLoading = true;
- import("@/vendor/Export2Excel").then(excel => {
- const tHeader = ["timestamp", "title", "type", "importance", "status"];
- const filterVal = [
- "timestamp",
- "title",
- "type",
- "importance",
- "status"
- ];
- const data = this.formatJson(filterVal, this.list);
- excel.export_json_to_excel({
- header: tHeader,
- data,
- filename: "table-list"
- });
- this.downloadLoading = false;
- });
- },
- formatJson(filterVal, jsonData) {
- return jsonData.map(v =>
- filterVal.map(j => {
- if (j === "timestamp") {
- return parseTime(v[j]);
- } else {
- return v[j];
- }
- })
- );
- }
- }
- };
- </script>
-
- <style rel="stylesheet/css" lang="scss" scoped></style>
- <style>
- .el-table td,
- .el-table th.is-leaf,
- .el-table--border,
- .el-table--group {
- border-color: #d0d3da;
- }
- .el-table--border::after,
- .el-table--group::after,
- .el-table::before {
- background-color: #d0d3da;
- }
- </style>
|