index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="公司编号" prop="fNo">
  5. <el-input
  6. v-model="queryParams.fNo"
  7. placeholder="请输入公司编号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="公司名称" prop="fName">
  14. <el-input
  15. v-model="queryParams.fName"
  16. placeholder="请输入公司名称"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="状态" prop="fStatus">
  23. <el-select v-model="queryParams.fStatus" placeholder="请选择状态" clearable size="small">
  24. <el-option label="请选择字典生成" value="" />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  29. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  30. </el-form-item>
  31. </el-form>
  32. <el-row :gutter="10" class="mb8">
  33. <el-col :span="1.5">
  34. <el-button
  35. type="primary"
  36. icon="el-icon-plus"
  37. size="mini"
  38. @click="handleAdd"
  39. v-hasPermi="['basicdata:company:add']"
  40. >新增</el-button>
  41. </el-col>
  42. <el-col :span="1.5">
  43. <el-button
  44. type="success"
  45. icon="el-icon-edit"
  46. size="mini"
  47. :disabled="single"
  48. @click="handleUpdate"
  49. v-hasPermi="['basicdata:company:edit']"
  50. >修改</el-button>
  51. </el-col>
  52. <el-col :span="1.5">
  53. <el-button
  54. type="danger"
  55. icon="el-icon-delete"
  56. size="mini"
  57. :disabled="multiple"
  58. @click="handleDelete"
  59. v-hasPermi="['basicdata:company:remove']"
  60. >删除</el-button>
  61. </el-col>
  62. <el-col :span="1.5">
  63. <el-button
  64. type="warning"
  65. icon="el-icon-download"
  66. size="mini"
  67. @click="handleExport"
  68. v-hasPermi="['basicdata:company:export']"
  69. >导出</el-button>
  70. </el-col>
  71. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  72. </el-row>
  73. <el-table v-loading="loading" :data="companyList" @selection-change="handleSelectionChange">
  74. <el-table-column type="selection" width="55" align="center" />
  75. <el-table-column label="状态" align="center" prop="fId" />
  76. <el-table-column label="公司编号" align="center" prop="fNo" />
  77. <el-table-column label="公司名称" align="center" prop="fName" />
  78. <el-table-column label="状态" align="center" prop="fStatus" />
  79. <el-table-column label="备注" align="center" prop="remark" />
  80. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150" fixed="right">
  81. <template slot-scope="scope">
  82. <el-button
  83. size="mini"
  84. type="text"
  85. icon="el-icon-edit"
  86. @click="handleUpdate(scope.row)"
  87. v-hasPermi="['basicdata:company:edit']"
  88. >修改</el-button>
  89. <el-button
  90. size="mini"
  91. type="text"
  92. icon="el-icon-delete"
  93. @click="handleDelete(scope.row)"
  94. v-hasPermi="['basicdata:company:remove']"
  95. >删除</el-button>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <pagination
  100. v-show="total>0"
  101. :total="total"
  102. :page.sync="queryParams.pageNum"
  103. :limit.sync="queryParams.pageSize"
  104. @pagination="getList"
  105. />
  106. <!-- 添加或修改公司名称对话框 -->
  107. <el-dialog :title="title" :visible.sync="open" close-on-click-modal="false" width="500px" append-to-body>
  108. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  109. <el-form-item label="公司编号" prop="fNo">
  110. <el-input v-model="form.fNo" placeholder="请输入公司编号" />
  111. </el-form-item>
  112. <el-form-item label="公司名称" prop="fName">
  113. <el-input v-model="form.fName" placeholder="请输入公司名称" />
  114. </el-form-item>
  115. <el-form-item label="状态">
  116. <el-radio-group v-model="form.fStatus">
  117. <el-radio label="1">请选择字典生成</el-radio>
  118. </el-radio-group>
  119. </el-form-item>
  120. <el-form-item label="删除状态" prop="delFlag">
  121. <el-input v-model="form.delFlag" placeholder="请输入删除状态" />
  122. </el-form-item>
  123. <el-form-item label="备注" prop="remark">
  124. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  125. </el-form-item>
  126. </el-form>
  127. <div slot="footer" class="dialog-footer">
  128. <el-button type="primary" @click="submitForm">确 定</el-button>
  129. <el-button @click="cancel">取 消</el-button>
  130. </div>
  131. </el-dialog>
  132. </div>
  133. </template>
  134. <script>
  135. import { listCompany, getCompany, delCompany, addCompany, updateCompany, exportCompany } from "../../../api/basicdata/company";
  136. export default {
  137. name: "Company",
  138. components: {
  139. },
  140. data() {
  141. return {
  142. // 遮罩层
  143. loading: true,
  144. // 选中数组
  145. ids: [],
  146. // 非单个禁用
  147. single: true,
  148. // 非多个禁用
  149. multiple: true,
  150. // 显示搜索条件
  151. showSearch: true,
  152. // 总条数
  153. total: 0,
  154. // 公司名称表格数据
  155. companyList: [],
  156. // 弹出层标题
  157. title: "",
  158. // 是否显示弹出层
  159. open: false,
  160. // 查询参数
  161. queryParams: {
  162. pageNum: 1,
  163. pageSize: 10,
  164. fNo: null,
  165. fName: null,
  166. fStatus: null,
  167. },
  168. // 表单参数
  169. form: {},
  170. // 表单校验
  171. rules: {
  172. fNo: [
  173. { required: true, message: "公司编号不能为空", trigger: "blur" }
  174. ],
  175. fName: [
  176. { required: true, message: "公司名称不能为空", trigger: "blur" }
  177. ],
  178. }
  179. };
  180. },
  181. created() {
  182. this.getList();
  183. },
  184. methods: {
  185. /** 查询公司名称列表 */
  186. getList() {
  187. this.loading = true;
  188. listCompany(this.queryParams).then(response => {
  189. this.companyList = response.rows;
  190. this.total = response.total;
  191. this.loading = false;
  192. });
  193. },
  194. // 取消按钮
  195. cancel() {
  196. this.open = false;
  197. this.reset();
  198. },
  199. // 表单重置
  200. reset() {
  201. this.form = {
  202. fId: null,
  203. fNo: null,
  204. fName: null,
  205. fStatus: "0",
  206. delFlag: null,
  207. createBy: null,
  208. createTime: null,
  209. updateBy: null,
  210. updateTime: null,
  211. remark: null
  212. };
  213. this.resetForm("form");
  214. },
  215. /** 搜索按钮操作 */
  216. handleQuery() {
  217. this.queryParams.pageNum = 1;
  218. this.getList();
  219. },
  220. /** 重置按钮操作 */
  221. resetQuery() {
  222. this.resetForm("queryForm");
  223. this.handleQuery();
  224. },
  225. // 多选框选中数据
  226. handleSelectionChange(selection) {
  227. this.ids = selection.map(item => item.fId)
  228. this.single = selection.length!==1
  229. this.multiple = !selection.length
  230. },
  231. /** 新增按钮操作 */
  232. handleAdd() {
  233. this.reset();
  234. this.open = true;
  235. this.title = "添加公司名称";
  236. },
  237. /** 修改按钮操作 */
  238. handleUpdate(row) {
  239. this.reset();
  240. const fId = row.fId || this.ids
  241. getCompany(fId).then(response => {
  242. this.form = response.data;
  243. this.open = true;
  244. this.title = "修改公司名称";
  245. });
  246. },
  247. /** 提交按钮 */
  248. submitForm() {
  249. this.$refs["form"].validate(valid => {
  250. if (valid) {
  251. if (this.form.fId != null) {
  252. updateCompany(this.form).then(response => {
  253. this.msgSuccess("修改成功");
  254. this.open = false;
  255. this.getList();
  256. });
  257. } else {
  258. addCompany(this.form).then(response => {
  259. this.msgSuccess("新增成功");
  260. this.open = false;
  261. this.getList();
  262. });
  263. }
  264. }
  265. });
  266. },
  267. /** 删除按钮操作 */
  268. handleDelete(row) {
  269. const fIds = row.fId || this.ids;
  270. this.$confirm('是否确认删除公司名称编号为"' + fIds + '"的数据项?', "警告", {
  271. confirmButtonText: "确定",
  272. cancelButtonText: "取消",
  273. type: "warning"
  274. }).then(function() {
  275. return delCompany(fIds);
  276. }).then(() => {
  277. this.getList();
  278. this.msgSuccess("删除成功");
  279. })
  280. },
  281. /** 导出按钮操作 */
  282. handleExport() {
  283. const queryParams = this.queryParams;
  284. this.$confirm('是否确认导出所有公司名称数据项?', "警告", {
  285. confirmButtonText: "确定",
  286. cancelButtonText: "取消",
  287. type: "warning"
  288. }).then(function() {
  289. return exportCompany(queryParams);
  290. }).then(response => {
  291. this.download(response.msg);
  292. })
  293. }
  294. }
  295. };
  296. </script>