supplierManage.vue 13 KB

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