index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10" class="mb8">
  4. <el-col :span="1.5">
  5. <el-button
  6. v-hasPermi="['controller:info:add']"
  7. type="primary"
  8. icon="el-icon-plus"
  9. size="mini"
  10. @click="handleAdd"
  11. >新增</el-button
  12. >
  13. </el-col>
  14. <el-col :span="1.5">
  15. <el-button
  16. v-hasPermi="['controller:info:update']"
  17. type="success"
  18. icon="el-icon-edit"
  19. size="mini"
  20. :disabled="single"
  21. @click="handleUpdate"
  22. >修改</el-button
  23. >
  24. </el-col>
  25. <el-col :span="1.5">
  26. <el-button
  27. v-hasPermi="['controller:info:remove']"
  28. type="danger"
  29. icon="el-icon-delete"
  30. size="mini"
  31. :disabled="multiple"
  32. @click="handleDelete"
  33. >删除</el-button
  34. >
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-button
  38. type="warning"
  39. icon="el-icon-download"
  40. size="mini"
  41. @click="handleExport"
  42. >导出</el-button
  43. >
  44. </el-col>
  45. <el-col :span="1.5">
  46. <el-upload
  47. v-hasPermi="['controller:info:import']"
  48. :show-file-list="false"
  49. class="upload-demo"
  50. with-credentials
  51. :headers="{
  52. Authorization: 'Bearer ' + token,
  53. }"
  54. action="http://xxgl.zzxcx.net/stage-api/controller/info/import"
  55. :on-success="handleSuccess"
  56. multiple
  57. accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
  58. :file-list="fileList"
  59. >
  60. <el-button
  61. type="warning"
  62. icon="el-icon-bottom"
  63. size="mini"
  64. v-hasPermi="['controller:info:import']"
  65. >导入</el-button
  66. >
  67. </el-upload>
  68. </el-col>
  69. <right-toolbar
  70. :showSearch.sync="showSearch"
  71. @queryTable="getList"
  72. ></right-toolbar>
  73. </el-row>
  74. <el-table
  75. v-loading="loading"
  76. :data="infoList"
  77. @selection-change="handleSelectionChange"
  78. >
  79. <el-table-column type="selection" width="55" align="center" />
  80. <el-table-column label="品牌" align="center" prop="brand" />
  81. <el-table-column
  82. label="控制器型号"
  83. align="center"
  84. prop="controllerModel"
  85. />
  86. <el-table-column
  87. label="控制器价格"
  88. align="center"
  89. prop="controllerPrice"
  90. />
  91. <el-table-column
  92. label="操作"
  93. align="center"
  94. class-name="small-padding fixed-width"
  95. >
  96. <template slot-scope="scope">
  97. <el-button
  98. size="mini"
  99. type="text"
  100. icon="el-icon-edit"
  101. @click="handleUpdate(scope.row)"
  102. >修改</el-button
  103. >
  104. <el-button
  105. @click="
  106. () => {
  107. $router.push('/gallery?id=' + scope.row.id + '&type=3');
  108. }
  109. "
  110. size="mini"
  111. type="text"
  112. icon="el-icon-picture-outline"
  113. >图片</el-button
  114. >
  115. <el-button
  116. size="mini"
  117. type="text"
  118. icon="el-icon-delete"
  119. @click="handleDelete(scope.row)"
  120. >删除</el-button
  121. >
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. <pagination
  126. v-show="total > 0"
  127. :total="total"
  128. :page.sync="queryParams.pageNum"
  129. :limit.sync="queryParams.pageSize"
  130. @pagination="getList"
  131. />
  132. <!-- 添加或修改控制器报价对话框 -->
  133. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  134. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  135. <el-form-item label="品牌" prop="brand">
  136. <el-input v-model="form.brand" placeholder="请输入品牌" />
  137. </el-form-item>
  138. <el-form-item label="控制器型号" prop="controllerModel">
  139. <el-input
  140. v-model="form.controllerModel"
  141. placeholder="请输入控制器型号"
  142. />
  143. </el-form-item>
  144. <el-form-item label="控制器价格" prop="controllerPrice">
  145. <el-input
  146. v-model="form.controllerPrice"
  147. placeholder="请输入控制器价格"
  148. />
  149. </el-form-item>
  150. </el-form>
  151. <div slot="footer" class="dialog-footer">
  152. <el-button type="primary" @click="submitForm">确 定</el-button>
  153. <el-button @click="cancel">取 消</el-button>
  154. </div>
  155. </el-dialog>
  156. </div>
  157. </template>
  158. <script>
  159. import {
  160. listInfo,
  161. getInfo,
  162. delInfo,
  163. addInfo,
  164. updateInfo,
  165. exportInfo,
  166. } from "@/api/price/controller";
  167. import { getToken } from "@/utils/auth";
  168. export default {
  169. name: "Info",
  170. data() {
  171. return {
  172. token: getToken(),
  173. // 遮罩层
  174. loading: true,
  175. // 选中数组
  176. ids: [],
  177. // 非单个禁用
  178. single: true,
  179. // 非多个禁用
  180. multiple: true,
  181. // 显示搜索条件
  182. showSearch: true,
  183. // 总条数
  184. total: 0,
  185. // 控制器报价表格数据
  186. infoList: [],
  187. // 弹出层标题
  188. title: "",
  189. // 是否显示弹出层
  190. open: false,
  191. // 查询参数
  192. queryParams: {
  193. pageNum: 1,
  194. pageSize: 10,
  195. brand: null,
  196. controllerModel: null,
  197. controllerPrice: null,
  198. },
  199. // 表单参数
  200. form: {},
  201. // 表单校验
  202. rules: {},
  203. };
  204. },
  205. created() {
  206. this.getList();
  207. },
  208. methods: {
  209. handleSuccess() {
  210. this.msgSuccess("上传成功");
  211. this.getList();
  212. // this.getList()
  213. },
  214. /** 查询控制器报价列表 */
  215. getList() {
  216. this.loading = true;
  217. listInfo(this.queryParams).then((response) => {
  218. this.infoList = response.rows;
  219. this.total = response.total;
  220. this.loading = false;
  221. });
  222. },
  223. // 取消按钮
  224. cancel() {
  225. this.open = false;
  226. this.reset();
  227. },
  228. // 表单重置
  229. reset() {
  230. this.form = {
  231. id: null,
  232. brand: null,
  233. controllerModel: null,
  234. controllerPrice: null,
  235. updateTime: null,
  236. createTime: null,
  237. };
  238. this.resetForm("form");
  239. },
  240. /** 搜索按钮操作 */
  241. handleQuery() {
  242. this.queryParams.pageNum = 1;
  243. this.getList();
  244. },
  245. /** 重置按钮操作 */
  246. resetQuery() {
  247. this.resetForm("queryForm");
  248. this.handleQuery();
  249. },
  250. // 多选框选中数据
  251. handleSelectionChange(selection) {
  252. this.ids = selection.map((item) => item.id);
  253. this.single = selection.length !== 1;
  254. this.multiple = !selection.length;
  255. },
  256. /** 新增按钮操作 */
  257. handleAdd() {
  258. this.reset();
  259. this.open = true;
  260. this.title = "添加控制器报价";
  261. },
  262. /** 修改按钮操作 */
  263. handleUpdate(row) {
  264. this.reset();
  265. const id = row.id || this.ids;
  266. getInfo(id).then((response) => {
  267. this.form = response.data;
  268. this.open = true;
  269. this.title = "修改控制器报价";
  270. });
  271. },
  272. /** 提交按钮 */
  273. submitForm() {
  274. this.$refs["form"].validate((valid) => {
  275. if (valid) {
  276. if (this.form.id != null) {
  277. updateInfo(this.form).then((response) => {
  278. this.msgSuccess("修改成功");
  279. this.open = false;
  280. this.getList();
  281. });
  282. } else {
  283. addInfo(this.form).then((response) => {
  284. this.msgSuccess("新增成功");
  285. this.open = false;
  286. this.getList();
  287. });
  288. }
  289. }
  290. });
  291. },
  292. /** 删除按钮操作 */
  293. handleDelete(row) {
  294. const ids = row.id || this.ids;
  295. this.$confirm(
  296. '是否确认删除控制器报价编号为"' + ids + '"的数据项?',
  297. "警告",
  298. {
  299. confirmButtonText: "确定",
  300. cancelButtonText: "取消",
  301. type: "warning",
  302. }
  303. )
  304. .then(function () {
  305. return delInfo(ids);
  306. })
  307. .then(() => {
  308. this.getList();
  309. this.msgSuccess("删除成功");
  310. });
  311. },
  312. /** 导出按钮操作 */
  313. handleExport() {
  314. const queryParams = this.queryParams;
  315. this.$confirm("是否确认导出所有控制器报价数据项?", "警告", {
  316. confirmButtonText: "确定",
  317. cancelButtonText: "取消",
  318. type: "warning",
  319. })
  320. .then(function () {
  321. return exportInfo(queryParams);
  322. })
  323. .then((response) => {
  324. this.download(response.data);
  325. });
  326. },
  327. },
  328. };
  329. </script>