index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <div class="app-container">
  3. <!-- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="供应商类型(三种) " prop="providerType">
  5. <el-select v-model="queryParams.providerType" placeholder="请选择供应商类型(三种) " clearable filterable>
  6. <el-option
  7. v-for="dict in dict.type.${dictType}"
  8. :key="dict.value"
  9. :label="dict.label"
  10. :value="dict.value"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  16. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  17. </el-form-item>
  18. </el-form> -->
  19. <el-row :gutter="10" class="mb8">
  20. <el-col :span="1.5">
  21. <el-button
  22. type="primary"
  23. plain
  24. icon="el-icon-plus"
  25. size="mini"
  26. v-if="checkPermi(['business:ENTERPRISESCREENDATA:add'])"
  27. @click="handleAdd"
  28. >新增</el-button
  29. >
  30. </el-col>
  31. <el-col :span="1.5">
  32. <el-button
  33. type="success"
  34. plain
  35. icon="el-icon-edit"
  36. size="mini"
  37. v-if="checkPermi(['business:ENTERPRISESCREENDATA:edit'])"
  38. :disabled="single"
  39. @click="handleUpdate"
  40. >修改</el-button
  41. >
  42. </el-col>
  43. <el-col :span="1.5">
  44. <el-button
  45. type="danger"
  46. plain
  47. icon="el-icon-delete"
  48. size="mini"
  49. v-if="checkPermi(['business:ENTERPRISESCREENDATA:remove'])"
  50. :disabled="multiple"
  51. @click="handleDelete"
  52. >删除</el-button
  53. >
  54. </el-col>
  55. <!-- <el-col :span="1.5">
  56. <el-button
  57. type="warning"
  58. plain
  59. icon="el-icon-download"
  60. size="mini"
  61. @click="handleExport"
  62. >导出</el-button
  63. >
  64. </el-col> -->
  65. <right-toolbar
  66. :showSearch.sync="showSearch"
  67. @queryTable="getList"
  68. ></right-toolbar>
  69. </el-row>
  70. <el-table
  71. :data="ENTERPRISESCREENDATAList"
  72. @selection-change="handleSelectionChange"
  73. >
  74. <el-table-column type="selection" width="55" align="center" />
  75. <el-table-column label="企业名称" align="center" prop="enterpriseName">
  76. </el-table-column>
  77. <el-table-column label="供应商名称 " align="center" prop="providerName">
  78. </el-table-column>
  79. <el-table-column
  80. label="供应商类型(三种) "
  81. align="center"
  82. prop="providerType"
  83. >
  84. </el-table-column>
  85. <el-table-column
  86. label="操作"
  87. align="center"
  88. class-name="small-padding fixed-width"
  89. >
  90. <template slot-scope="scope">
  91. <el-button
  92. size="mini"
  93. type="text"
  94. icon="el-icon-edit"
  95. v-if="checkPermi(['business:ENTERPRISESCREENDATA:edit'])"
  96. @click="handleUpdate(scope.row)"
  97. >修改</el-button
  98. >
  99. <el-button
  100. size="mini"
  101. type="text"
  102. icon="el-icon-delete"
  103. v-if="checkPermi(['business:ENTERPRISESCREENDATA:remove'])"
  104. @click="handleDelete(scope.row)"
  105. >删除</el-button
  106. >
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. <pagination
  111. v-show="total > 0"
  112. :total="total"
  113. :page.sync="queryParams.pageNum"
  114. :limit.sync="queryParams.pageSize"
  115. @pagination="getList"
  116. />
  117. <!-- 添加或修改企业大屏所需供应商数据对话框 -->
  118. <el-dialog
  119. :title="title"
  120. :visible.sync="open"
  121. :close-on-click-modal="false"
  122. width="35%"
  123. append-to-body
  124. >
  125. <el-form ref="form" :model="form" :rules="rules" label-width="140px">
  126. <el-row>
  127. <el-col :span="24">
  128. <el-form-item label="企业名称" prop="enterpriseName">
  129. <el-select
  130. @change="selectDept"
  131. v-model="form.enterpriseName"
  132. placeholder="请选择供应商类型(三种) "
  133. filterable
  134. >
  135. <el-option
  136. v-for="(dict, index) in deptList"
  137. :key="index"
  138. :label="dict.deptName"
  139. :value="index"
  140. ></el-option>
  141. </el-select>
  142. </el-form-item>
  143. </el-col>
  144. <el-col :span="24">
  145. <el-form-item label="供应商类型(三种)" prop="providerType">
  146. <el-select
  147. v-model="form.providerType"
  148. placeholder="请选择供应商类型(三种) "
  149. filterable
  150. >
  151. <el-option
  152. v-for="dict in tyleLabel"
  153. :key="dict.value"
  154. :label="dict.label"
  155. :value="dict.value"
  156. ></el-option>
  157. </el-select>
  158. </el-form-item>
  159. </el-col>
  160. <el-col :span="24">
  161. <el-form-item label="供应商名称" prop="providerName" width="120px">
  162. <el-input
  163. placeholder="供应商名称 "
  164. v-model="form.providerName"
  165. ></el-input>
  166. </el-form-item>
  167. </el-col>
  168. </el-row>
  169. </el-form>
  170. <div slot="footer" class="dialog-footer">
  171. <el-button type="primary" @click="submitForm">确 定</el-button>
  172. <el-button @click="cancel">取 消</el-button>
  173. </div>
  174. </el-dialog>
  175. </div>
  176. </template>
  177. <script>
  178. import {
  179. listENTERPRISESCREENDATA,
  180. getENTERPRISESCREENDATA,
  181. delENTERPRISESCREENDATA,
  182. addENTERPRISESCREENDATA,
  183. updateENTERPRISESCREENDATA,
  184. } from "@/api/portal/ENTERPRISESCREENDATA/ENTERPRISESCREENDATA";
  185. import { checkPermi } from "@/utils/permission.js";
  186. import { getUserProfile } from "@/api/system/user.js";
  187. import { listDept } from "@/api/system/dept.js";
  188. export default {
  189. name: "ENTERPRISESCREENDATA",
  190. data() {
  191. return {
  192. // 供应商类型
  193. tyleLabel: [
  194. {
  195. label: "上游供应商",
  196. value: "上游供应商",
  197. },
  198. {
  199. label: "下游供应商",
  200. value: "下游供应商",
  201. },
  202. {
  203. label: "供应链服务商",
  204. value: "供应链服务商",
  205. },
  206. ],
  207. // 部门列表
  208. deptList: [],
  209. // 根路径
  210. baseURL: process.env.VUE_APP_BASE_API,
  211. // 遮罩层
  212. loading: true,
  213. // 选中数组
  214. ids: [],
  215. // 非单个禁用
  216. single: true,
  217. // 非多个禁用
  218. multiple: true,
  219. // 显示搜索条件
  220. showSearch: true,
  221. // 总条数
  222. total: 0,
  223. // 企业大屏所需供应商数据表格数据
  224. ENTERPRISESCREENDATAList: [],
  225. // 弹出层标题
  226. title: "",
  227. // 是否显示弹出层
  228. open: false,
  229. // 查询参数
  230. queryParams: {
  231. pageNum: 1,
  232. pageSize: 10,
  233. id: null,
  234. enterpriseName: null,
  235. providerName: null,
  236. providerType: null,
  237. createTime: null,
  238. createBy: null,
  239. updateTime: null,
  240. updateBy: null,
  241. deeptId: null,
  242. },
  243. // 表单参数
  244. form: {},
  245. // 表单校验
  246. rules: {
  247. id: [
  248. {
  249. required: true,
  250. message: "企业大屏所需数据主键不能为空",
  251. trigger: "blur",
  252. },
  253. ],
  254. enterpriseName: [
  255. { required: true, message: "企业名称不能为空", trigger: "blur" },
  256. ],
  257. providerName: [
  258. { required: true, message: "供应商名称 不能为空", trigger: "blur" },
  259. ],
  260. providerType: [
  261. {
  262. required: true,
  263. message: "供应商类型(三种) 不能为空",
  264. trigger: "change",
  265. },
  266. ],
  267. deeptId: [
  268. { required: true, message: "部门主键不能为空", trigger: "blur" },
  269. ],
  270. },
  271. // 用户数据
  272. userData: {},
  273. };
  274. },
  275. created() {
  276. this.getList();
  277. getUserProfile().then((res) => {
  278. this.userData = res.data;
  279. listDept({ parentId: this.userData.deptId }).then((data) => {
  280. this.deptList = data.data;
  281. console.log(this.deptList);
  282. });
  283. });
  284. },
  285. methods: {
  286. checkPermi,
  287. /** 查询企业大屏所需供应商数据列表 */
  288. getList() {
  289. // this.loading = true;
  290. listENTERPRISESCREENDATA(this.queryParams).then((response) => {
  291. this.ENTERPRISESCREENDATAList = response.rows;
  292. this.total = response.total;
  293. // this.loading = false;
  294. });
  295. },
  296. // 取消按钮
  297. cancel() {
  298. this.open = false;
  299. this.reset();
  300. },
  301. selectDept(i) {
  302. this.form.enterpriseName = this.deptList[i].deptName;
  303. this.form.deeptId = this.deptList[i].deptId;
  304. },
  305. // 表单重置
  306. reset() {
  307. this.form = {
  308. enterpriseName: null,
  309. providerName: null,
  310. providerType: null,
  311. deeptId: null,
  312. };
  313. this.resetForm("form");
  314. },
  315. /** 搜索按钮操作 */
  316. handleQuery() {
  317. this.queryParams.pageNum = 1;
  318. this.getList();
  319. },
  320. /** 重置按钮操作 */
  321. resetQuery() {
  322. this.resetForm("queryForm");
  323. this.handleQuery();
  324. },
  325. // 多选框选中数据
  326. handleSelectionChange(selection) {
  327. this.ids = selection.map((item) => item.id);
  328. this.single = selection.length !== 1;
  329. this.multiple = !selection.length;
  330. },
  331. /** 新增按钮操作 */
  332. handleAdd() {
  333. this.reset();
  334. this.open = true;
  335. this.title = "添加企业大屏所需供应商数据";
  336. },
  337. /** 修改按钮操作 */
  338. handleUpdate(row) {
  339. this.reset();
  340. const id = row.id || this.ids;
  341. getENTERPRISESCREENDATA(id).then((response) => {
  342. this.form = response.data;
  343. this.open = true;
  344. this.title = "修改企业大屏所需供应商数据";
  345. });
  346. },
  347. /** 提交按钮 */
  348. submitForm() {
  349. console.log(this.form, "---");
  350. this.$refs["form"].validate((valid) => {
  351. // this.form.deeptId = this.userData.deptId;
  352. if (valid) {
  353. if (this.form.id != null) {
  354. updateENTERPRISESCREENDATA(this.form).then((response) => {
  355. this.$modal.msgSuccess("修改成功");
  356. this.open = false;
  357. this.getList();
  358. });
  359. } else {
  360. addENTERPRISESCREENDATA(this.form).then((response) => {
  361. this.$modal.msgSuccess("新增成功");
  362. this.open = false;
  363. this.getList();
  364. });
  365. }
  366. }
  367. });
  368. },
  369. /** 删除按钮操作 */
  370. handleDelete(row) {
  371. const ids = row.id || this.ids;
  372. this.$modal
  373. .confirm(
  374. '是否确认删除企业大屏所需供应商数据编号为"' + ids + '"的数据项?'
  375. )
  376. .then(function () {
  377. return delENTERPRISESCREENDATA(ids);
  378. })
  379. .then(() => {
  380. this.getList();
  381. this.$modal.msgSuccess("删除成功");
  382. })
  383. .catch(() => {});
  384. },
  385. /** 导出按钮操作 */
  386. handleExport() {
  387. this.download(
  388. "business/ENTERPRISESCREENDATA/export",
  389. {
  390. ...this.queryParams,
  391. },
  392. `ENTERPRISESCREENDATA_${new Date().getTime()}.xlsx`
  393. );
  394. },
  395. },
  396. };
  397. </script>