data_previllege_add_org.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <el-dialog
  3. ref="dialog"
  4. title="添加中心"
  5. width="900px"
  6. :visible.sync="visible"
  7. @close="closeDialog"
  8. >
  9. <el-form
  10. ref="form"
  11. :model="form"
  12. :rules="rules"
  13. :inline="true"
  14. label-position="right"
  15. label-width="80px"
  16. >
  17. <el-row>
  18. <el-form-item label="中心名称">
  19. <el-input v-model="form.name" placeholder="请输入中心名称" />
  20. </el-form-item>
  21. <el-form-item label="中心代码">
  22. <el-input v-model="form.code" placeholder="请输入中心代码" />
  23. </el-form-item>
  24. <!-- <el-form-item label="负责人">
  25. <el-input placeholder="请输入中心名称" v-model="form.contact" />
  26. </el-form-item> -->
  27. <el-form-item>
  28. <el-button
  29. size="small"
  30. type="primary"
  31. icon="el-icon-search"
  32. @click="search"
  33. >
  34. 查询
  35. </el-button>
  36. </el-form-item>
  37. </el-row>
  38. <el-row>
  39. <div>
  40. <el-table
  41. ref="table"
  42. :data="tableData"
  43. border
  44. resizable
  45. stripe
  46. style="width: 100%"
  47. >
  48. <el-table-column type="selection" width="40" />
  49. <el-table-column width="85" label="中心ID">
  50. <span slot-scope="scope">{{ scope.row.id }}</span>
  51. </el-table-column>
  52. <el-table-column width="200" label="中心代码">
  53. <span slot-scope="scope">{{ scope.row.code }}</span>
  54. </el-table-column>
  55. <el-table-column label="中心名称">
  56. <span slot-scope="scope">{{ scope.row.name }}</span>
  57. </el-table-column>
  58. <el-table-column width="100" label="负责人">
  59. <span slot-scope="scope">{{ scope.row.contacts }}</span>
  60. </el-table-column>
  61. </el-table>
  62. <div class="page pull-right">
  63. <el-pagination
  64. v-if="paginationShow"
  65. :current-page="currentPage"
  66. :page-size="pageSize"
  67. :page-sizes="[10, 20, 50, 100, 200, 300]"
  68. layout="total, sizes, prev, pager, next, jumper"
  69. :total="total"
  70. @current-change="handleCurrentChange"
  71. @size-change="handleSizeChange"
  72. />
  73. </div>
  74. </div>
  75. <div style="margin-bottom: 20px"></div>
  76. </el-row>
  77. <el-row class="d-flex justify-content-center mt-2">
  78. <el-button type="primary" :loading="loading" @click="submitForm"
  79. >确 定</el-button
  80. >
  81. <el-button @click="closeDialog">取 消</el-button>
  82. </el-row>
  83. </el-form>
  84. </el-dialog>
  85. </template>
  86. <script>
  87. import { CORE_API } from "@/constants/constants";
  88. export default {
  89. name: "DataPrevillegeAddOrgDialog",
  90. props: {
  91. userId: { type: String, default: "" },
  92. rootOrgId: { type: String, default: "" },
  93. },
  94. data() {
  95. return {
  96. visible: false,
  97. form: {
  98. // parentId: this.$store.state.user.rootOrgId,
  99. name: "",
  100. code: "",
  101. },
  102. rules: {},
  103. loading: false,
  104. paginationShow: false,
  105. tableData: [],
  106. noBatchSelected: true,
  107. currentPage: 1,
  108. pageSize: 10,
  109. total: 10,
  110. };
  111. },
  112. methods: {
  113. async search() {
  114. var param = new URLSearchParams({
  115. ...this.form,
  116. parentId: this.rootOrgId,
  117. });
  118. var url =
  119. CORE_API +
  120. "/org/subOrgPage/" +
  121. (this.currentPage - 1) +
  122. "/" +
  123. this.pageSize +
  124. "?" +
  125. param;
  126. this.loading = true;
  127. return this.$httpWithMsg.get(url).then((response) => {
  128. this.tableData = response.data.list;
  129. this.total = response.data.total;
  130. this.loading = false;
  131. this.paginationShow = true;
  132. });
  133. },
  134. async openDialog() {
  135. this.visible = true;
  136. try {
  137. await this.search();
  138. } catch (error) {
  139. console.log(error);
  140. this.$notify({ type: "error", title: "获取中心列表失败" });
  141. }
  142. },
  143. closeDialog() {
  144. this.visible = false;
  145. },
  146. handleSizeChange(val) {
  147. this.pageSize = val;
  148. this.currentPage = 1;
  149. this.search();
  150. },
  151. handleCurrentChange(val) {
  152. this.currentPage = val;
  153. this.search();
  154. },
  155. async submitForm() {
  156. try {
  157. await this.$refs.form.validate();
  158. } catch (error) {
  159. console.log("校验失败", error);
  160. return;
  161. }
  162. const refIds = this.$refs.table.selection.map((v) => v.id);
  163. console.log(refIds);
  164. if (refIds.length === 0) {
  165. this.$notify({ type: "warning", message: "请先选择一行或多行" });
  166. return;
  167. }
  168. try {
  169. this.loading = true;
  170. // await saveActivity(data);
  171. await this.$httpWithMsg.post(CORE_API + "/user/data/rule/add", {
  172. refIds,
  173. type: "ORG",
  174. userId: this.userId,
  175. });
  176. this.$emit("reload");
  177. this.$notify({ title: "保存成功", type: "success" });
  178. this.closeDialog();
  179. } finally {
  180. this.loading = false;
  181. }
  182. },
  183. },
  184. };
  185. </script>
  186. <style></style>