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

drugTable.vue 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <div class="" style="margin-right:20px;">
  3. <el-table
  4. style="margin-top: 42px;"
  5. :row-style="{ color: '#303133' }"
  6. :header-cell-style="{
  7. backgroundColor: 'rgb(245, 247, 250)',
  8. color: '#606266'
  9. }"
  10. :key="tableKey"
  11. :data="list"
  12. v-loading="listLoading"
  13. border
  14. fit
  15. highlight-current-row
  16. @current-change="handleRowChange"
  17. >
  18. <el-table-column align="center" label="名称">
  19. <template slot-scope="scope">
  20. <span>{{ scope.row.name }}</span>
  21. </template>
  22. </el-table-column>
  23. <el-table-column align="center" label="字段名">
  24. <template slot-scope="scope">
  25. <span>{{ scope.row.field_name }}</span>
  26. </template>
  27. </el-table-column>
  28. </el-table>
  29. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
  30. <el-form
  31. :rules="rules"
  32. ref="dataForm"
  33. :model="temp"
  34. label-width="70px"
  35. style="width: 500px; margin-left:50px;"
  36. >
  37. <el-form-item :label="$t('data_config.config_name')" prop="config_name">
  38. <el-input v-model="temp.name" placeholder="请输入名称"></el-input>
  39. </el-form-item>
  40. <el-form-item
  41. :label="$t('data_config.config_field')"
  42. prop="config_field"
  43. >
  44. <el-input
  45. v-model="temp.field_name"
  46. placeholder="请输入字段名称"
  47. ></el-input>
  48. </el-form-item>
  49. <el-form-item :label="$t('data_config.remark')">
  50. <el-input
  51. type="textarea"
  52. :autosize="{ minRows: 4, maxRows: 4 }"
  53. placeholder="请输入备注"
  54. v-model="temp.remark"
  55. >
  56. </el-input>
  57. </el-form-item>
  58. </el-form>
  59. <div slot="footer" class="dialog-footer">
  60. <el-button @click="dialogFormVisible = false">{{
  61. $t("table.cancel")
  62. }}</el-button>
  63. <el-button
  64. v-if="dialogStatus == 'create'"
  65. type="primary"
  66. @click="createData"
  67. >{{ $t("table.confirm") }}</el-button
  68. >
  69. <el-button v-else type="primary" @click="updateData">{{
  70. $t("table.confirm")
  71. }}</el-button>
  72. </div>
  73. </el-dialog>
  74. <el-dialog title="Reading statistics" :visible.sync="dialogPvVisible">
  75. <el-table
  76. :data="pvData"
  77. border
  78. fit
  79. highlight-current-row
  80. style="width: 100%"
  81. >
  82. <el-table-column prop="key" label="Channel"> </el-table-column>
  83. <el-table-column prop="pv" label="Pv"> </el-table-column>
  84. </el-table>
  85. <span slot="footer" class="dialog-footer">
  86. <el-button type="primary" @click="dialogPvVisible = false">{{
  87. $t("table.confirm")
  88. }}</el-button>
  89. </span>
  90. </el-dialog>
  91. </div>
  92. </template>
  93. <script>
  94. import { createDictionaryConfig } from "@/api/data";
  95. import waves from "@/directive/waves"; // 水波纹指令
  96. import { parseTime } from "@/utils";
  97. import store from "@/store";
  98. import bus from "@/assets/eventBus";
  99. import { getDictionaryDataConfig } from "@/utils/data";
  100. export default {
  101. name: "drugTable",
  102. directives: {
  103. waves
  104. },
  105. props: {
  106. type: {
  107. type: String,
  108. default: "patient"
  109. }
  110. },
  111. data() {
  112. return {
  113. currentId: undefined,
  114. tableKey: 0,
  115. // list: null,
  116. total: null,
  117. listLoading: true,
  118. listQuery: {
  119. page: 1,
  120. limit: 20,
  121. importance: undefined,
  122. title: undefined,
  123. type: this.type,
  124. sort: "+id"
  125. },
  126. importanceOptions: [1, 2, 3],
  127. // calendarTypeOptions,
  128. sortOptions: [
  129. { label: "ID Ascending", key: "+id" },
  130. { label: "ID Descending", key: "-id" }
  131. ],
  132. statusOptions: ["published", "draft", "deleted"],
  133. showReviewer: false,
  134. temp: {
  135. id: undefined,
  136. parent_id: 0,
  137. module: this.type,
  138. org_id: 0,
  139. name: "",
  140. field_name: undefined,
  141. value: "",
  142. remark: ""
  143. },
  144. dialogFormVisible: false,
  145. dialogStatus: "",
  146. textMap: {
  147. update: "修改",
  148. create: "新增"
  149. },
  150. dialogPvVisible: false,
  151. pvData: [],
  152. rules: {
  153. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  154. field_name: [
  155. { required: true, message: "请输入字段名", trigger: "blur" }
  156. ],
  157. config_value: [
  158. { required: false, message: "title is required", trigger: "blur" }
  159. ]
  160. },
  161. downloadLoading: false
  162. };
  163. },
  164. watch: {
  165. "temp.config_field": function() {
  166. this.temp.config_field = this.temp.config_field.replace(/[^A-Za-z]/g, "");
  167. }
  168. },
  169. computed: {
  170. list: function() {
  171. // const list = store.getters.configlist[this.type]
  172. // this.total = list.length
  173. return store.getters.dictionary_configlist['system'];
  174. }
  175. },
  176. filters: {
  177. statusFilter(status) {
  178. const statusMap = {
  179. published: "success",
  180. draft: "info",
  181. deleted: "danger"
  182. };
  183. return statusMap[status];
  184. },
  185. typeFilter(type) {
  186. return calendarTypeKeyValue[type];
  187. }
  188. },
  189. created() {
  190. this.getList();
  191. },
  192. methods: {
  193. fieldChange: function(newValue) {
  194. this.temp.config_field = newValue.replace(/[^A-Za-z]/g, "");
  195. },
  196. handleRowChange(currentRow, oldCurrentRow) {
  197. if (currentRow != undefined) {
  198. this.currentId = currentRow.id;
  199. bus.$emit("drugParentChangeId", currentRow);
  200. }
  201. },
  202. getList() {
  203. // debugger
  204. // var test = getConfig('patient','blood_types')
  205. this.listLoading = true;
  206. setTimeout(() => {
  207. this.listLoading = false;
  208. }, 1 * 1000);
  209. },
  210. handleFilter() {
  211. this.listQuery.page = 1;
  212. this.getList();
  213. },
  214. handleSizeChange(val) {
  215. this.listQuery.limit = val;
  216. this.getList();
  217. },
  218. handleCurrentChange(val) {
  219. this.listQuery.page = val;
  220. this.getList();
  221. },
  222. handleModifyStatus(row, status) {
  223. this.$message({
  224. message: "操作成功",
  225. type: "success"
  226. });
  227. row.status = status;
  228. },
  229. resetTemp() {
  230. this.temp = {
  231. id: undefined,
  232. parent_id: 0,
  233. module: this.type,
  234. org_id: 0,
  235. name: "",
  236. field_name: undefined,
  237. value: "",
  238. remark: ""
  239. };
  240. },
  241. handleCreate() {
  242. this.resetTemp();
  243. this.dialogStatus = "create";
  244. this.dialogFormVisible = true;
  245. this.$nextTick(() => {
  246. this.$refs["dataForm"].clearValidate();
  247. });
  248. },
  249. createData() {
  250. this.$refs["dataForm"].validate(valid => {
  251. if (valid) {
  252. createDictionaryConfig(this.temp).then(response => {
  253. if (!response.data) {
  254. // 由于mockjs 不支持自定义状态码只能这样hack
  255. reject("error");
  256. }
  257. if (response.data.state === 0) {
  258. this.$message.error(response.data.msg);
  259. }
  260. const result = response.data.data.dataconfig;
  261. // 更新store
  262. store.dispatch("updateDictionaryConfigList", result).then(() => {});
  263. this.dialogFormVisible = false;
  264. this.$message.success("创建成功");
  265. });
  266. }
  267. });
  268. },
  269. handleUpdate(row) {
  270. this.temp = Object.assign({}, row); // copy obj
  271. this.temp.timestamp = new Date(this.temp.timestamp);
  272. this.dialogStatus = "update";
  273. this.dialogFormVisible = true;
  274. this.$nextTick(() => {
  275. this.$refs["dataForm"].clearValidate();
  276. });
  277. },
  278. updateData() {
  279. this.$refs["dataForm"].validate(valid => {
  280. if (valid) {
  281. const tempData = Object.assign({}, this.temp);
  282. tempData.timestamp = +new Date(tempData.timestamp); // change Thu Nov 30 2017 16:41:05 GMT+0800 (CST) to 1512031311464
  283. updateArticle(tempData).then(() => {
  284. for (const v of this.list) {
  285. if (v.id === this.temp.id) {
  286. const index = this.list.indexOf(v);
  287. this.list.splice(index, 1, this.temp);
  288. break;
  289. }
  290. }
  291. this.dialogFormVisible = false;
  292. this.$message.success("更新成功");
  293. });
  294. }
  295. });
  296. },
  297. handleDelete(row) {
  298. this.$message.success("删除成功");
  299. const index = this.list.indexOf(row);
  300. this.list.splice(index, 1);
  301. },
  302. handleFetchPv(pv) {
  303. fetchPv(pv).then(response => {
  304. this.pvData = response.data.pvData;
  305. this.dialogPvVisible = true;
  306. });
  307. },
  308. handleDownload() {
  309. this.downloadLoading = true;
  310. import("@/vendor/Export2Excel").then(excel => {
  311. const tHeader = ["timestamp", "title", "type", "importance", "status"];
  312. const filterVal = [
  313. "timestamp",
  314. "title",
  315. "type",
  316. "importance",
  317. "status"
  318. ];
  319. const data = this.formatJson(filterVal, this.list);
  320. excel.export_json_to_excel({
  321. header: tHeader,
  322. data,
  323. filename: "table-list"
  324. });
  325. this.downloadLoading = false;
  326. });
  327. },
  328. formatJson(filterVal, jsonData) {
  329. return jsonData.map(v =>
  330. filterVal.map(j => {
  331. if (j === "timestamp") {
  332. return parseTime(v[j]);
  333. } else {
  334. return v[j];
  335. }
  336. })
  337. );
  338. }
  339. }
  340. };
  341. </script>
  342. <style>
  343. .el-table td,
  344. .el-table th.is-leaf,
  345. .el-table--border,
  346. .el-table--group {
  347. border-color: #d0d3da;
  348. }
  349. .el-table--border::after,
  350. .el-table--group::after,
  351. .el-table::before {
  352. background-color: #d0d3da;
  353. }
  354. </style>