index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div class="app-container">
  3. <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
  4. <el-table-column v-if="false" label="自增主键id" align="center" prop="deptId" />
  5. <el-table-column label="油站名称" align="center" prop="deptName" />
  6. <el-table-column label="油站地址" align="center" prop="deptAddress" />
  7. <el-table-column label="油枪数量" align="center" prop="oilGunNum" />
  8. <el-table-column label="联系人" align="center" prop="contacts" />
  9. <el-table-column label="电话" align="center" prop="phone" />
  10. <el-table-column v-if="false" label="集团id" align="center" prop="stationGroupId" />
  11. <el-table-column v-if="false" label="集团名称" align="center" prop="stationGroupName" />
  12. <el-table-column v-if="false" label="油站照片" align="center" prop="stationPic" />
  13. <el-table-column label="油站经度" align="center" prop="stationLongitude" />
  14. <el-table-column label="油站纬度" align="center" prop="stationLatitude" />
  15. <el-table-column label="商户编码" align="center" prop="mno" />
  16. <el-table-column label="操作" align="c--enter" class-name="small-padding fixed-width">
  17. <template slot-scope="scope">
  18. <el-button
  19. size="mini"
  20. type="text"
  21. icon="el-icon-edit"
  22. @click="handleUpdate(scope.row)"
  23. v-hasPermi="['station:info:edit']"
  24. >修改</el-button>
  25. </template>
  26. </el-table-column>
  27. </el-table>
  28. <pagination
  29. v-show="total>0"
  30. :total="total"
  31. :page.sync="queryParams.pageNum"
  32. :limit.sync="queryParams.pageSize"
  33. @pagination="getList"
  34. />
  35. <!-- 添加或修改油站信息对话框 -->
  36. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  37. <el-form ref="form" :model="form" :rules="rules" label-width="90px">
  38. <el-form-item label="油站形象照" prop="stationPic">
  39. <el-upload
  40. class="avatar-uploader"
  41. action="http://localhost:8080/common/upload"
  42. :show-file-list="false"
  43. :headers=headers
  44. :on-success="handleAvatarSuccess"
  45. :before-upload="beforeAvatarUpload">
  46. <img v-if="form.stationPic" :src="form.stationPic" style="width:150px;height: 150px;" class="avatar">
  47. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  48. </el-upload>
  49. </el-form-item>
  50. <el-form-item label="油站名称" prop="deptName">
  51. <el-input v-model="form.deptName" placeholder="请输入油站名称" />
  52. </el-form-item>
  53. <el-form-item label="油站地址" prop="deptAddress">
  54. <el-input v-model="form.deptAddress" placeholder="请输入油站地址" />
  55. </el-form-item>
  56. <el-form-item label="油枪数量" prop="oilGunNum">
  57. <el-input v-model="form.oilGunNum" placeholder="请输入油枪数量" />
  58. </el-form-item>
  59. <el-form-item label="联系人" prop="leader">
  60. <el-input v-model="form.leader" placeholder="请输入联系人" />
  61. </el-form-item>
  62. <el-form-item label="电话" prop="phone">
  63. <el-input v-model="form.phone" placeholder="请输入电话" />
  64. </el-form-item>
  65. <!-- <el-form-item label="集团名称" prop="parentId">-->
  66. <!-- <treeselect v-model="form.parentId" :options="deptOptions" @select="selectDepart" :show-count="true" placeholder="请选择归属集团" />-->
  67. <!-- </el-form-item>-->
  68. <!-- <el-form-item label="集团名称" prop="stationGroupName" v-show="false">-->
  69. <!-- <el-input v-model="form.stationGroupName" placeholder="请输入所属集团名称" />-->
  70. <!-- </el-form-item>-->
  71. <el-form-item label="油站经度" prop="stationLongitude">
  72. <el-input v-model="form.stationLongitude" :disabled="true" placeholder="请输入油站经度" />
  73. </el-form-item>
  74. <el-form-item label="油站纬度" prop="stationLatitude">
  75. <el-input v-model="form.stationLatitude" :disabled="true" placeholder="请输入油站纬度" />
  76. </el-form-item>
  77. <el-form-item label="商户编码" prop="mno">
  78. <el-input v-model="form.mno" :disabled="true" placeholder="请输入商户编码" />
  79. </el-form-item>
  80. <el-form-item label="小程序appid" prop="appId">
  81. <el-input v-model="form.appId" :disabled="true" placeholder="小程序appid" />
  82. </el-form-item>
  83. <el-form-item label="小程序appSecret" prop="appSecret">
  84. <el-input v-model="form.appSecret" :disabled="true" placeholder="小程序appSecret" />
  85. </el-form-item>
  86. </el-form>
  87. <div slot="footer" class="dialog-footer">
  88. <el-button type="primary" @click="submitForm">确 定</el-button>
  89. <el-button @click="cancel">取 消</el-button>
  90. </div>
  91. </el-dialog>
  92. </div>
  93. </template>
  94. <script>
  95. import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo } from "@/api/station/info";
  96. import { getToken } from "@/utils/auth";
  97. import { treeselect } from "@/api/system/dept";
  98. import Treeselect from "@riophae/vue-treeselect";
  99. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  100. export default {
  101. name: "Info",
  102. components: { Treeselect },
  103. data() {
  104. return {
  105. // 遮罩层
  106. loading: true,
  107. // 选中数组
  108. ids: [],
  109. // 非单个禁用
  110. single: true,
  111. // 非多个禁用
  112. multiple: true,
  113. // 显示搜索条件
  114. showSearch: true,
  115. // 总条数
  116. total: 0,
  117. // 油站信息表格数据
  118. infoList: [],
  119. // 部门树选项
  120. deptOptions: undefined,
  121. // 弹出层标题
  122. title: "",
  123. // 是否显示弹出层
  124. open: false,
  125. // 查询参数
  126. queryParams: {
  127. pageNum: 1,
  128. pageSize: 10,
  129. stationName: null,
  130. deptAddress: null,
  131. oilGunNum: null,
  132. contacts: null,
  133. phone: null,
  134. stationGroupName: null,
  135. stationPic: null,
  136. stationLongitude: null,
  137. stationLatitude: null,
  138. mno: null
  139. },
  140. // 表单参数
  141. form: {},
  142. // 表单校验
  143. rules: {
  144. },
  145. imageUrl: '',
  146. headers: { Authorization: "Bearer " + getToken() }
  147. };
  148. },
  149. created() {
  150. this.getList();
  151. this.getTreeselect();
  152. },
  153. methods: {
  154. /** 查询油站信息列表 */
  155. getList() {
  156. this.loading = true;
  157. listInfo(this.queryParams).then(response => {
  158. this.infoList = response.rows;
  159. this.total = response.total;
  160. this.loading = false;
  161. });
  162. },
  163. getTreeselect() {
  164. treeselect().then(response => {
  165. this.deptOptions = response.data;
  166. });
  167. },
  168. // 获取当前选中部门的名称
  169. selectDepart(val) {
  170. this.form.stationGroupName=val.label;
  171. },
  172. // 取消按钮
  173. cancel() {
  174. this.open = false;
  175. this.reset();
  176. },
  177. // 表单重置
  178. reset() {
  179. this.form = {
  180. deptId: null,
  181. deptName: null,
  182. deptAddress: null,
  183. oilGunNum: null,
  184. contacts: null,
  185. phone: null,
  186. stationGroupId: null,
  187. stationGroupName: null,
  188. stationPic: null,
  189. stationLongitude: null,
  190. stationLatitude: null,
  191. mno: null
  192. };
  193. this.resetForm("form");
  194. },
  195. /** 搜索按钮操作 */
  196. handleQuery() {
  197. this.queryParams.pageNum = 1;
  198. this.getList();
  199. },
  200. /** 重置按钮操作 */
  201. resetQuery() {
  202. this.resetForm("queryForm");
  203. this.handleQuery();
  204. },
  205. // 多选框选中数据
  206. handleSelectionChange(selection) {
  207. this.ids = selection.map(item => item.stationId)
  208. this.single = selection.length!==1
  209. this.multiple = !selection.length
  210. },
  211. /** 新增按钮操作 */
  212. handleAdd() {
  213. this.reset();
  214. this.open = true;
  215. this.title = "添加油站信息";
  216. },
  217. /** 修改按钮操作 */
  218. handleUpdate(row) {
  219. this.reset();
  220. const deptId = row.deptId || this.ids
  221. getInfo(deptId).then(response => {
  222. this.form = response.data;
  223. this.open = true;
  224. this.title = "修改油站信息";
  225. });
  226. // this.upload.fileList = [{ name: this.form.fileName, url: this.form.filePath }];
  227. },
  228. /** 提交按钮 */
  229. submitForm() {
  230. this.$refs["form"].validate(valid => {
  231. if (valid) {
  232. if (this.form.deptId != null) {
  233. updateInfo(this.form).then(response => {
  234. this.msgSuccess("修改成功");
  235. this.open = false;
  236. this.getList();
  237. });
  238. }
  239. }
  240. });
  241. },
  242. /** 删除按钮操作 */
  243. handleDelete(row) {
  244. const stationIds = row.deptId || this.ids;
  245. this.$confirm('是否确认删除油站信息编号为"' + stationIds + '"的数据项?', "警告", {
  246. confirmButtonText: "确定",
  247. cancelButtonText: "取消",
  248. type: "warning"
  249. }).then(function() {
  250. return delInfo(stationIds);
  251. }).then(() => {
  252. this.getList();
  253. this.msgSuccess("删除成功");
  254. })
  255. },
  256. /** 导出按钮操作 */
  257. handleExport() {
  258. const queryParams = this.queryParams;
  259. this.$confirm('是否确认导出所有油站信息数据项?', "警告", {
  260. confirmButtonText: "确定",
  261. cancelButtonText: "取消",
  262. type: "warning"
  263. }).then(function() {
  264. return exportInfo(queryParams);
  265. }).then(response => {
  266. this.download(response.msg);
  267. })
  268. },
  269. // 文件提交处理
  270. submitUpload() {
  271. this.$refs.upload.submit();
  272. },
  273. // 文件上传中处理
  274. handleFileUploadProgress(event, file, fileList) {
  275. this.upload.isUploading = true;
  276. },
  277. // 文件上传成功处理++ =
  278. handleFileSuccess(response, file, fileList) {
  279. this.upload.isUploading = false;
  280. this.form.filePath = response.url;
  281. this.msgSuccess(response.msg);
  282. },
  283. handleAvatarSuccess(res, file) {
  284. this.form.stationPic = res.url;
  285. },
  286. beforeAvatarUpload(file) {
  287. const isJPG = file.type === 'image/jpeg';
  288. const isLt2M = file.size / 1024 / 1024 < 2;
  289. if (!isJPG) {
  290. this.$message.error('上传头像图片只能是 JPG 格式!');
  291. }
  292. if (!isLt2M) {
  293. this.$message.error('上传头像图片大小不能超过 2MB!');
  294. }
  295. return isJPG && isLt2M;
  296. }
  297. }
  298. };
  299. </script>