supplierManage.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <!--供应商管理-->
  2. <template>
  3. <div class="app-container supplier">
  4. <div class="supplier_handle-page" v-if="pageType == 1">
  5. <el-form :model="queryParams" ref="queryForm" style="margin-top:20px;" :inline="true" label-width="120">
  6. <el-form-item label="关键字" prop="name">
  7. <el-input
  8. v-model="queryParams.searchValue"
  9. placeholder="名称/联系人/联系方式"
  10. clearable
  11. maxLength="30"
  12. size="small"
  13. />
  14. </el-form-item>
  15. <el-form-item label="状态" prop="zgType" label-width="80px">
  16. <el-select v-model="queryParams.status" placeholder="请选择" clearable size="small">
  17. <el-option label="启用" value="0" />
  18. <el-option label="禁用" value="1" />
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item>
  22. <p class="inquire-button-one" @click="handleQuery">查询</p>
  23. <p class="reset-button-one" @click="resetQuery">重置</p>
  24. </el-form-item>
  25. <el-form-item label="" prop="title" style="float: right">
  26. <el-dropdown @command="exportButton" style="float: left" v-hasPermi="['airbottle:taskManage:export']">
  27. <div class="form-dropdown-box">
  28. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_sc.png">
  29. <p>导出</p>
  30. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  31. </div>
  32. <el-dropdown-menu slot="dropdown">
  33. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{command:1}">导出全部数据</el-dropdown-item>
  34. <el-dropdown-item style="margin:0 10px;color:#666;" :command="{command:2}">导出选中数据</el-dropdown-item>
  35. </el-dropdown-menu>
  36. </el-dropdown>
  37. <el-col :span="1.5" style="margin-left: 10px;">
  38. <p class="add-button-one-120"
  39. @click="handleClick('','','add')"
  40. v-hasPermi="['airbottle:supplier:add']"
  41. ><i class="el-icon-plus"></i>新增供应商</p>
  42. </el-col>
  43. <p class="inquire-button-one" v-hasPermi="['airbottle:audit:edit']" style="width: 120px;margin-left: 10px;" @click="handleClick('','','audit')">审核供应商</p>
  44. </el-form-item>
  45. </el-form>
  46. <el-table border v-loading="loading" :data="tableData" @selection-change="handleSelectionChange" ref="multipleTable" :row-key="getRowKeys">
  47. <el-table-column type="selection" width="50" align="center"/>
  48. <el-table-column label="供应商名称" align="left" prop="companyName"/>
  49. <el-table-column label="供应商简称" align="left" prop="companyShort"></el-table-column>
  50. <el-table-column label="联系人" align="left" prop="contacts"></el-table-column>
  51. <el-table-column label="联系方式" align="left" prop="phone"></el-table-column>
  52. <el-table-column label="运输人员" align="left" prop="peopleSum"></el-table-column>
  53. <el-table-column label="运输车辆" align="left" prop="carSum"></el-table-column>
  54. <el-table-column label="气瓶" align="left" prop="bottleSum"></el-table-column>
  55. <el-table-column label="状态" align="left" prop="status">
  56. <template slot-scope="scope">
  57. <el-switch
  58. class="switch"
  59. @change="switchChange(scope.row)"
  60. v-model="scope.row.status+''"
  61. active-value="0"
  62. inactive-value="1"
  63. active-text="启用"
  64. inactive-text="禁用"
  65. >
  66. </el-switch>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="180">
  70. <template slot-scope="scope">
  71. <div style="display: flex;height:30px;">
  72. <p v-hasPermi="['airbottle:supplier:query']" class="table-min-button" @click="handleClick('',scope.row,'detail')">查看</p>
  73. <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)">
  74. <span class="table-min-button">
  75. 更多<i class="el-icon-d-arrow-right el-icon--right"></i>
  76. </span>
  77. <el-dropdown-menu slot="dropdown">
  78. <el-dropdown-item command="edit" icon="el-icon-edit-outline" v-hasPermiAnd="['airbottle:supplier:edit']">编辑</el-dropdown-item>
  79. <el-dropdown-item command="delete" icon="el-icon-delete" v-hasPermiAnd="['airbottle:supplier:remove']">删除</el-dropdown-item>
  80. </el-dropdown-menu>
  81. </el-dropdown>
  82. </div>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. <div style="display: flex;height:32px;margin-top:15px;">
  87. <!--<p style="flex:4;"></p>-->
  88. <p style="text-align: left;margin:0;line-height:32px;margin-right:20px;font-size:14px;color:#999;">
  89. <i class="el-icon-warning" style="color:#0183FA;"></i>
  90. 已选择 {{selectedNum}} 项
  91. </p>
  92. <div style="flex:5;">
  93. <pagination :page-sizes="[20, 30, 40, 50]"
  94. v-show="total>0"
  95. :total="total"
  96. style="margin:0;"
  97. :page.sync="queryParams.pageNum"
  98. :limit.sync="queryParams.pageSize"
  99. @pagination="getList"
  100. />
  101. </div>
  102. </div>
  103. </div>
  104. <!--新增页面-->
  105. <add-page v-if="pageType==2" :pageData="pageData"></add-page>
  106. <!--详情页面-->
  107. <detail-page v-if="pageType==3" :pageData2="pageData2"></detail-page>
  108. <!--审核页面-->
  109. <check-page v-if="pageType==4"></check-page>
  110. </div>
  111. </template>
  112. <script>
  113. import { supplierDelete, supplierList, supplierStop } from '@/api/gasManage3_0/gasManage'
  114. import { getToken } from "@/utils/auth";
  115. import addPage from "./supplierManageAdd.vue"
  116. import detailPage from "./supplierManageDetail.vue"
  117. import checkPage from "./supplierManageCheckList.vue"
  118. export default {
  119. name: "Approval",
  120. components: {
  121. addPage,
  122. detailPage,
  123. checkPage
  124. },
  125. data() {
  126. return {
  127. //页面状态
  128. pageType:1,
  129. loading:false,
  130. headers: {
  131. Authorization: "Bearer " + getToken()
  132. },
  133. // 查询参数
  134. queryParams: {
  135. pageNum: 1,
  136. pageSize:20,
  137. name:'',
  138. },
  139. total:0,
  140. tableData:[{}],
  141. dateRange:[],
  142. pageData:{},
  143. pageData2:{},
  144. //导出
  145. //表格扩展选择器---需要在@selection-change绑定的方法内监控selection数组长度
  146. selectedNum:0,
  147. // 选中数组
  148. ids: [],
  149. // 非单个禁用
  150. single: true,
  151. // 非多个禁用
  152. multiple: true,
  153. };
  154. },
  155. methods: {
  156. handleClick(index,row,doType){
  157. let _this=this;
  158. if(doType=='export'){//导出
  159. this.download('airbottle/supplier/export', {
  160. ...this.queryParams
  161. }, `供应商记录导出.xlsx`)
  162. }else if(doType=='add'){//添加
  163. _this.pageData.status=0;
  164. _this.pageData.id='';
  165. _this.pageType=2;
  166. }else if(doType=='detail'){//详情
  167. _this.pageData2.id=row.id;
  168. _this.pageType=3;
  169. }else if(doType=='audit'){//审核
  170. _this.pageType=4;
  171. }else if(doType=='back'){//审核
  172. _this.pageType=1;
  173. }
  174. },
  175. /** 当前时间 */
  176. getCurrentTime () {
  177. const yy = new Date().getFullYear()
  178. const mm = new Date().getMonth() + 1
  179. const dd = new Date().getDate()
  180. const hh = new Date().getHours()
  181. const mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
  182. const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
  183. return yy + '-' + mm + '-' + dd
  184. },
  185. /** 导出按钮操作 */
  186. exportButton(item) {
  187. let self = this;
  188. let currentDate = this.getCurrentTime()
  189. if(item.command == 1){
  190. self.$confirm(`确认导出全部数据?`, "提示", {
  191. confirmButtonText: "确定",
  192. cancelButtonText: "取消",
  193. type: "warning"
  194. }).then(async () => {
  195. self.download('/airbottle/supplier/export/', {...self.queryParamsData}, '供应商记录导出-'+currentDate+'.xlsx')
  196. }).catch(() => {})
  197. }else if(item.command == 2){
  198. if(self.ids.length>0) {
  199. self.$confirm(`确认导出选中数据?`, "提示", {
  200. confirmButtonText: "确定",
  201. cancelButtonText: "取消",
  202. type: "warning"
  203. }).then(async () => {
  204. let ids = self.ids.join(',');
  205. let obj = {
  206. ids :ids
  207. }
  208. console.log("obj",obj)
  209. self.download(`/airbottle/supplier/export/`,obj, '供应商记录导出-'+currentDate+'.xlsx')
  210. }).catch(() => {})
  211. }else {
  212. this.msgError('请选择要导出的数据')
  213. }
  214. }
  215. },
  216. // 多选框选中数据
  217. handleSelectionChange(selection) {
  218. this.selectedNum = selection.length;
  219. this.ids = selection.map(item => item.id);
  220. this.single = selection.length != 1;
  221. this.multiple = !selection.length;
  222. },
  223. /*===记录勾选数据===
  224. 需要再el-table 添加 :row-key="getRowKeys"
  225. 需要在selection 添加 :reserve-selection="true"
  226. */
  227. getRowKeys(row) {
  228. return row.id
  229. },
  230. // 更多操作触发
  231. handleCommand(command, row) {
  232. let _this=this;
  233. switch (command) {
  234. case "edit":
  235. _this.pageData.status=1;
  236. _this.pageData.id=row.id;
  237. _this.pageType=2;
  238. break;
  239. case "delete":
  240. this.handleDelete(row);
  241. break;
  242. default:
  243. break;
  244. }
  245. },
  246. /** 删除按钮操作 */
  247. handleDelete(row) {
  248. let _this=this
  249. this.$confirm('是否确认删除?', "警告", {
  250. confirmButtonText: "确定",
  251. cancelButtonText: "取消",
  252. type: "warning"
  253. }).then(function() {
  254. supplierDelete(row.id).then( response => {
  255. _this.msgSuccess("删除成功");
  256. _this.getList();
  257. });
  258. }).then(() => {
  259. _this.getList();
  260. }).catch(() => {});
  261. },
  262. //状态
  263. switchChange(row){
  264. console.log(row.status)
  265. //1上架0下架
  266. this.$confirm('是否确定'+(row.status==1?'启用':'禁用')+'?', '提示', {
  267. confirmButtonText: '确定',
  268. cancelButtonText: '取消',
  269. type: 'warning'
  270. }).then(() => {
  271. this.upDownShelf(row.id,row.status==0?1:0)
  272. }).catch(() => {
  273. this.$message({
  274. type: 'info',
  275. message: '已取消'
  276. });
  277. });
  278. },
  279. //上架下架
  280. upDownShelf(id,status){
  281. let obj = {
  282. id:id,
  283. status:status,//课程状态 0 下架,1 上架
  284. };
  285. supplierStop(obj).then( response => {
  286. this.msgSuccess(status==0?"启用供应商成功!":'停用供应商成功!');
  287. this.getList();
  288. });
  289. },
  290. /** 导出按钮操作 */
  291. handleExport() {
  292. this.download('system/hazard/export', {
  293. ...this.queryParams
  294. }, `system_hazard.xlsx`)
  295. },
  296. /** 搜索按钮操作 */
  297. handleQuery() {
  298. this.queryParams.pageNum = 1;
  299. this.getList();
  300. },
  301. /** 重置按钮操作 */
  302. resetQuery() {
  303. this.queryParams.searchValue = "";
  304. this.queryParams.status = "";
  305. this.handleQuery();
  306. },
  307. getList(){
  308. let _this=this;
  309. supplierList(_this.queryParams).then( response => {
  310. let res=response.rows;
  311. _this.tableData=res;
  312. _this.total=response.total;
  313. });
  314. },
  315. },
  316. mounted() {
  317. this.getList()
  318. }
  319. };
  320. </script>
  321. <style scoped lang="scss">
  322. /*导出按钮样式*/
  323. .form-dropdown-box{
  324. display: flex;
  325. margin:0;
  326. padding:0 10px;
  327. cursor: pointer;
  328. height:40px;
  329. img:nth-child(1){
  330. width:16px;
  331. height:16px;
  332. margin-top:12px;
  333. }
  334. p{
  335. width:47px;
  336. text-align: center;
  337. font-size:14px;
  338. margin:0;
  339. line-height:40px;
  340. }
  341. img:nth-child(3){
  342. width:10px;
  343. height:6px;
  344. margin-top:17px;
  345. }
  346. }
  347. .supplier {
  348. display: flex!important;
  349. flex-direction: column;
  350. .supplier_handle-page{
  351. flex:1;
  352. display: flex!important;
  353. flex-direction: column;
  354. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  355. padding:20px 20px 20px!important;
  356. border-radius:10px;
  357. .button-box{
  358. width:200px;
  359. display: flex;
  360. }
  361. }
  362. }
  363. </style>
  364. <style lang="scss">
  365. .supplier{
  366. .supplier_handle-page{
  367. .switch .el-switch__label {
  368. position: absolute;
  369. display: none;
  370. color: #fff !important;
  371. }
  372. .switch .el-switch__label--right {
  373. z-index: 1;
  374. }
  375. .switch .el-switch__label--right span{
  376. margin-right:10px;
  377. }
  378. .switch .el-switch__label--left {
  379. z-index: 1;
  380. }
  381. .switch .el-switch__label--left span{
  382. margin-left: 14px;
  383. }
  384. .switch .el-switch__label.is-active {
  385. display: block;
  386. }
  387. .switch.el-switch .el-switch__core,
  388. .el-switch .el-switch__label {
  389. width: 64px !important;
  390. margin: 0;
  391. }
  392. }
  393. }
  394. </style>