You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

392 lines
11 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <script setup>
  2. import { ref } from "vue";
  3. import { ElMessage } from "element-plus";
  4. import { ElMessageBox } from "element-plus";
  5. import axios from "axios";
  6. import moment from "moment";
  7. const titleEdit = ref(false);
  8. const raiseEdit = ref(false);
  9. const addInfo = ref(false);
  10. const deleteInfo = ref(false);
  11. //这是查询的接口
  12. const info = ref({});
  13. const getInfo = async function () {
  14. try {
  15. const result = await axios.get("http://192.168.9.117:8092/page");
  16. info.value.title = result.data.data.title;
  17. info.value.targetNumber = result.data.data.targetNumber;
  18. } catch (error) {
  19. console.log("请求失败", error);
  20. }
  21. };
  22. getInfo();
  23. //这是修改标题的接口
  24. const titleNew = ref({});
  25. const putTitle = async function () {
  26. try {
  27. // 创建一个FormData对象
  28. const formData = new FormData();
  29. // 将titleNew中的数据添加到FormData对象中
  30. for (const key in titleNew.value) {
  31. formData.append(key, titleNew.value[key]);
  32. }
  33. const result = await axios.put(
  34. "http://192.168.9.117:8092/title",
  35. formData,
  36. {
  37. headers: {
  38. "Content-Type": "multipart/form-data",
  39. },
  40. }
  41. );
  42. if (result.data.code == 10000) {
  43. ElMessage.success("修改成功");
  44. titleEdit.value = false;
  45. titleNew.value = {};
  46. getInfo(); //刷新页面
  47. }
  48. if (result.data.code == 10001) {
  49. ElMessage.error(result.data.msg);
  50. titleNew.value = {};
  51. titleEdit.value = false;
  52. }
  53. } catch (error) {
  54. console.log("请求失败", error);
  55. }
  56. };
  57. //这是修改众筹人数的接口
  58. const targetNumberNew = ref({});
  59. const putTargetNumber = async function () {
  60. try {
  61. // 创建一个FormData对象
  62. const formData = new FormData();
  63. // 将titleNew中的数据添加到FormData对象中
  64. for (const key in targetNumberNew.value) {
  65. formData.append(key, targetNumberNew.value[key]);
  66. }
  67. const result = await axios.put(
  68. "http://192.168.9.117:8092/target",
  69. formData,
  70. {
  71. headers: {
  72. "Content-Type": "multipart/form-data",
  73. },
  74. }
  75. );
  76. if (result.data.code == 10000) {
  77. ElMessage.success("修改成功");
  78. raiseEdit.value = false;
  79. targetNumberNew.value = {};
  80. getInfo(); //刷新页面
  81. }
  82. if (result.data.code == 10001) {
  83. ElMessage.error(result.data.msg);
  84. targetNumberNew.value = {};
  85. raiseEdit.value = false;
  86. }
  87. } catch (error) {
  88. console.log("请求失败", error);
  89. }
  90. };
  91. //这是查询全部数据的接口
  92. const search = ref({
  93. jwcode: "",
  94. identity: "",
  95. });
  96. const tableData = ref([]);
  97. const get = async function () {
  98. try {
  99. const result = await axios.post(
  100. "http://192.168.9.117:8092/users",
  101. search.value
  102. );
  103. tableData.value = result.data.data;
  104. } catch (error) {
  105. console.log("请求失败", error);
  106. }
  107. };
  108. get();
  109. //这是添加的接口
  110. const add = ref({});
  111. const addUser = async function () {
  112. try {
  113. const result = await axios.post(
  114. "http://192.168.9.117:8092/addUser",
  115. add.value
  116. );
  117. if (result.data.code == 10000) {
  118. ElMessage.success("修改成功");
  119. addInfo.value = false;
  120. add.value = {};
  121. get(); //刷新页面
  122. }
  123. if (result.data.code == 10001) {
  124. ElMessage.error(result.data.msg);
  125. addInfo.value = false;
  126. add.value = {};
  127. }
  128. } catch (error) {
  129. console.log("请求失败", error);
  130. }
  131. };
  132. // 这是删除的接口
  133. const idname = ref("");
  134. function deleteRow(value) {
  135. deleteInfo.value = true;
  136. console.log(value);
  137. idname.value = value;
  138. }
  139. const tureDelete = async function () {
  140. try {
  141. const result = await axios.delete(
  142. "http://192.168.9.117:8092/delUser/" + idname.value
  143. );
  144. if (result.data.code == 10000) {
  145. ElMessage.success("修改成功");
  146. deleteInfo.value = false;
  147. idname.value = {};
  148. get(); //刷新页面
  149. }
  150. if (result.data.code == 10001) {
  151. ElMessage.error(result.data.msg);
  152. deleteInfo.value = false;
  153. idname.value = {};
  154. }
  155. } catch (error) {
  156. console.log("请求失败", error);
  157. }
  158. };
  159. // 这是条件查询的接口
  160. const searchBy = ref({
  161. jwcode: "",
  162. identity: "",
  163. });
  164. const searchByJwcodeAndIdentity = async function () {
  165. try {
  166. const result = await axios.post(
  167. "http://192.168.9.117:8092/users",
  168. searchBy.value
  169. );
  170. if (result.data.code == 10000) {
  171. ElMessage.success("查询成功");
  172. }
  173. if (result.data.code == 10001) {
  174. ElMessage.error(result.data.msg);
  175. }
  176. tableData.value = result.data.data;
  177. } catch (error) {
  178. console.log("请求失败", error);
  179. }
  180. };
  181. function Nono() {
  182. searchBy.value = {};
  183. get();
  184. }
  185. </script>
  186. <template>
  187. <el-container>
  188. <el-main style="width: 100%">
  189. <el-card style="min-width: 70%; margin: 0 auto">
  190. <h2 style="margin-top: 0%">众筹活动界面后台</h2>
  191. <h3>修改前台展示</h3>
  192. <el-divider style="margin-top: 0%" />
  193. <div style="display: flex; align-items: center">
  194. <h4 style="margin: 0%">当前标题:</h4>
  195. <span style="color: rgb(145, 145, 145); margin-left: 20px">{{
  196. info.title
  197. }}</span>
  198. <el-button
  199. class="xiugai"
  200. type="danger"
  201. style="
  202. display: inline-block;
  203. margin-left: 20px;
  204. color: rgb(245, 62, 62);
  205. margin-right: 50px;
  206. "
  207. @click="() => {titleEdit = true;titleNew.title = info.title}"
  208. >修改</el-button
  209. >
  210. <span style="color: rgb(145, 145, 145);;">标题最高可输入12个字符</span>
  211. </div>
  212. <div style="display: flex; align-items: center">
  213. <h4 style="margin-bottom: 0px; margin-top: 30px">众筹目标:</h4>
  214. <span
  215. style="
  216. margin-bottom: 0px;
  217. margin-top: 30px;
  218. margin-left: 20px;
  219. color: rgb(145, 145, 145);
  220. "
  221. >{{ info.targetNumber }}</span
  222. >
  223. <el-button
  224. class="xiugai"
  225. type="danger"
  226. style="
  227. display: inline-block;
  228. margin-left: 20px;
  229. margin-top: 30px;
  230. color: rgb(245, 62, 62);
  231. "
  232. @click="() => {raiseEdit = true;targetNumberNew.targetNumber = info.targetNumber }"
  233. >修改</el-button
  234. >
  235. </div>
  236. </el-card>
  237. <el-card style="min-width: 70%; margin: 0 auto; margin-top: 20px">
  238. <h3>众筹用户列表</h3>
  239. <el-button type="danger" @click="addInfo = true">添加</el-button>
  240. <el-input
  241. v-model="searchBy.jwcode"
  242. style="width: 150px; margin-left: 200px"
  243. placeholder="精网号"
  244. ></el-input>
  245. <el-select
  246. v-model="searchBy.identity"
  247. style="width: 100px; margin-left: 60px"
  248. placeholder="身份"
  249. >
  250. <el-option label="真实" value="1"></el-option>
  251. <el-option label="虚拟" value="0"></el-option>
  252. </el-select>
  253. <el-button type="" @click="Nono()" style="margin-left: 40px"
  254. >重置</el-button
  255. >
  256. <el-button type="danger" @click="searchByJwcodeAndIdentity()"
  257. >查询</el-button
  258. >
  259. <el-table :data="tableData">
  260. <el-table-column
  261. label="序号"
  262. width="300px"
  263. type="index"
  264. >
  265. </el-table-column>
  266. <el-table-column
  267. prop="jwcode"
  268. label="编号"
  269. width="300px"
  270. ></el-table-column>
  271. <el-table-column prop="identity" label="身份" width="300px">
  272. <!-- 模板内容 -->
  273. <template #default="scope">
  274. <span v-if="scope.row.identity == 1">
  275. <span>真实</span>
  276. </span>
  277. <span v-if="scope.row.identity == 0">
  278. <span>虚拟</span>
  279. </span>
  280. </template>
  281. </el-table-column>
  282. <el-table-column prop="creatTime" label="参与时间" width="700px">
  283. <template #default="scope">
  284. {{ moment(scope.row.createTime).format("YYYY-MM-DD HH:mm:ss") }}
  285. </template>
  286. </el-table-column>
  287. <el-table-column label="操作" width="px">
  288. <template #default="scope">
  289. <el-button
  290. @click="deleteRow(scope.row.jwcode)"
  291. type="text"
  292. style="color: rgb(245, 62, 62)"
  293. >删除</el-button
  294. >
  295. </template>
  296. </el-table-column>
  297. </el-table>
  298. </el-card>
  299. </el-main>
  300. </el-container>
  301. <!-- 这是添加的弹窗 -->
  302. <el-dialog v-model="addInfo" width="500">
  303. <div>
  304. <h3 style="display: inline-block; margin-right: 20px">精网号</h3>
  305. <el-input
  306. v-model="add.jwcode"
  307. placeholder="请输入精网号"
  308. style="width: 300px; display: inline-block"
  309. />
  310. </div>
  311. <div>
  312. <h3 style="display: inline-block; margin-right: 20px">身份</h3>
  313. <el-radio-group v-model="add.identity">
  314. <el-radio value="1" size="large">真实</el-radio>
  315. <el-radio value="0" size="large">虚拟</el-radio>
  316. </el-radio-group>
  317. </div>
  318. <el-button type="danger" @click="addUser()" style="margin-left: 400px"
  319. >添加</el-button
  320. >
  321. </el-dialog>
  322. <!-- 这是修改表题的弹窗 -->
  323. <el-dialog v-model="titleEdit" width="500">
  324. <div>
  325. <h3 style="display: inline-block; margin-right: 20px">输入新标题</h3>
  326. <el-input
  327. v-model="titleNew.title"
  328. placeholder="请输入新标题"
  329. style="width: 300px; display: inline-block"
  330. />
  331. </div>
  332. <span style="color: rgb(145, 145, 145);;">标题最高可输入12个字符</span>
  333. <el-button type="danger" @click="putTitle()" style="margin-left: 400px"
  334. >确定</el-button
  335. >
  336. </el-dialog>
  337. <!-- 这是修改众筹目标的弹窗 -->
  338. <el-dialog v-model="raiseEdit" width="500">
  339. <div>
  340. <h3 style="display: inline-block; margin-right: 20px">
  341. 输入新众筹目标为
  342. </h3>
  343. <el-input
  344. v-model="targetNumberNew.targetNumber"
  345. placeholder="请输入阿拉伯数字"
  346. style="width: 300px; display: inline-block"
  347. />
  348. </div>
  349. <el-button
  350. type="danger"
  351. @click="putTargetNumber()"
  352. style="margin-left: 400px"
  353. >确定</el-button
  354. >
  355. </el-dialog>
  356. <!-- 这是删除的弹窗 -->
  357. <el-dialog v-model="deleteInfo" width="500">
  358. <div>
  359. <h3 style="display: inline-block; margin-right: 20px">
  360. 确认删除该条信息
  361. </h3>
  362. </div>
  363. <el-button type="danger" @click="tureDelete()" style="margin-left: 400px"
  364. >确定</el-button
  365. >
  366. </el-dialog>
  367. </template>
  368. <style scoped>
  369. /* 移除 el-button 的默认样式 */
  370. .xiugai {
  371. border: none;
  372. background-color: transparent;
  373. color: #409eff; /* Element Plus 默认的主题色 */
  374. padding: 0;
  375. font-size: inherit; /* 继承父元素的字体大小 */
  376. }
  377. </style>