index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!--仓库数据-->
  5. <el-col :span="4" :xs="24">
  6. <div class="head-container">
  7. <el-input
  8. v-model="fName"
  9. placeholder="请输入仓库名称"
  10. clearable
  11. size="small"
  12. prefix-icon="el-icon-search"
  13. style="margin-bottom: 20px"
  14. />
  15. </div>
  16. <div class="head-container">
  17. <el-tree
  18. :data="deptOptions"
  19. :props="defaultProps"
  20. :expand-on-click-node="false"
  21. :filter-node-method="filterNode"
  22. ref="tree"
  23. default-expand-all
  24. @node-click="handleNodeClick"
  25. />
  26. </div>
  27. </el-col>
  28. <!--库位数据-->
  29. <el-col :span="20" :xs="24">
  30. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  31. <el-form-item label="编号" prop="fNo">
  32. <el-input
  33. v-model="queryParams.fNo"
  34. placeholder="请输入编号"
  35. clearable
  36. size="small"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item label="名称" prop="fName">
  41. <el-input
  42. v-model="queryParams.fName"
  43. placeholder="请输入名称"
  44. clearable
  45. size="small"
  46. @keyup.enter.native="handleQuery"
  47. />
  48. </el-form-item>
  49. <el-form-item label="状态" prop="fStatus">
  50. <!--<el-select v-model="queryParams.fStatus" placeholder="请选择状态" clearable size="small">
  51. <el-option label="请选择字典生成" value="" />
  52. </el-select>-->
  53. <el-select
  54. v-model="queryParams.fStatus"
  55. placeholder="请选择状态"
  56. clearable
  57. size="small"
  58. style="width: 240px"
  59. >
  60. <el-option
  61. v-for="dict in statusOptions"
  62. :key="dict.dictValue"
  63. :label="dict.dictLabel"
  64. :value="dict.dictValue"
  65. />
  66. </el-select>
  67. </el-form-item>
  68. <el-form-item>
  69. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  70. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  71. </el-form-item>
  72. </el-form>
  73. <el-row :gutter="10" class="mb8">
  74. <el-col :span="1.5">
  75. <el-button
  76. type="primary"
  77. icon="el-icon-plus"
  78. size="mini"
  79. @click="handleAdd"
  80. v-hasPermi="['basicdata:warehouse:add']"
  81. >新增</el-button>
  82. </el-col>
  83. <el-col :span="1.5">
  84. <el-button
  85. type="success"
  86. icon="el-icon-edit"
  87. size="mini"
  88. :disabled="single"
  89. @click="handleUpdate"
  90. v-hasPermi="['basicdata:warehouse:edit']"
  91. >修改</el-button>
  92. </el-col>
  93. <el-col :span="1.5">
  94. <el-button
  95. type="danger"
  96. icon="el-icon-delete"
  97. size="mini"
  98. :disabled="multiple"
  99. @click="handleDelete"
  100. v-hasPermi="['basicdata:warehouse:remove']"
  101. >删除</el-button>
  102. </el-col>
  103. <el-col :span="1.5">
  104. <el-button
  105. type="warning"
  106. icon="el-icon-download"
  107. size="mini"
  108. @click="handleExport"
  109. v-hasPermi="['basicdata:warehouse:export']"
  110. >导出</el-button>
  111. </el-col>
  112. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  113. </el-row>
  114. <el-table v-loading="loading" :data="warehouseList" @selection-change="handleSelectionChange">
  115. <el-table-column type="selection" width="55" align="center" />
  116. <el-table-column type="index" label="序号" align="center"/>
  117. <el-table-column label="编号" align="center" prop="fNo" :show-overflow-tooltip="true" />
  118. <el-table-column label="名称" align="center" prop="fName" :show-overflow-tooltip="true" />
  119. <el-table-column label="录入人" align="center" prop="createBy" />
  120. <el-table-column label="录入时间" align="center" prop="createTime" width="180">
  121. <template slot-scope="scope">
  122. <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="状态" align="center">
  126. <template slot-scope="scope">
  127. <el-switch
  128. v-model="scope.row.fStatus"
  129. active-value="0"
  130. inactive-value="1"
  131. @change="handleStatusChange(scope.row)"
  132. ></el-switch>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
  136. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  137. <template slot-scope="scope">
  138. <el-button
  139. size="mini"
  140. type="text"
  141. icon="el-icon-edit"
  142. @click="handleUpdate(scope.row)"
  143. v-hasPermi="['basicdata:warehouse:edit']"
  144. >修改</el-button>
  145. <el-button
  146. size="mini"
  147. type="text"
  148. icon="el-icon-delete"
  149. @click="handleDelete(scope.row)"
  150. v-hasPermi="['basicdata:warehouse:remove']"
  151. >删除</el-button>
  152. </template>
  153. </el-table-column>
  154. </el-table>
  155. <pagination
  156. v-show="total>0"
  157. :total="total"
  158. :page.sync="queryParams.pageNum"
  159. :limit.sync="queryParams.pageSize"
  160. @pagination="getList"
  161. />
  162. </el-col>
  163. </el-row>
  164. <!-- 添加或修改仓库对话框 -->
  165. <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="60%" append-to-body>
  166. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  167. <el-row>
  168. <el-col :span="12">
  169. <el-form-item label="归属库区" prop="fWarehouseid">
  170. <treeselect v-model="form.fWarehouseid" :options="deptOptions" :show-count="true" placeholder="请选择归属库区" />
  171. </el-form-item>
  172. </el-col>
  173. </el-row>
  174. <el-row>
  175. <el-col :span="12">
  176. <el-form-item label="编号" prop="fNo">
  177. <el-input v-model="form.fNo" placeholder="请输入编号" />
  178. </el-form-item>
  179. </el-col>
  180. <el-col :span="12">
  181. <el-form-item label="名称" prop="fName">
  182. <el-input v-model="form.fName" placeholder="请输入名称" />
  183. </el-form-item>
  184. </el-col>
  185. </el-row>
  186. <el-row>
  187. <el-col :span="12">
  188. <el-form-item label="库容(吨)" prop="fTotalgross" >
  189. <el-input v-model="form.fTotalgross" placeholder="请输入库容(吨位)"/>
  190. </el-form-item>
  191. </el-col>
  192. <el-col :span="12">
  193. <el-form-item label="状态">
  194. <el-radio-group v-model="form.fStatus">
  195. <el-radio
  196. v-for="dict in statusOptions"
  197. :key="dict.dictValue"
  198. :label="dict.dictValue"
  199. >{{dict.dictLabel}}</el-radio>
  200. </el-radio-group>
  201. </el-form-item>
  202. </el-col>
  203. </el-row>
  204. <el-row>
  205. <el-col :span="24">
  206. <el-form-item label="备注" prop="remark">
  207. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  208. </el-form-item>
  209. </el-col>
  210. </el-row>
  211. </el-form>
  212. <div slot="footer" class="dialog-footer">
  213. <el-button type="primary" @click="submitForm">确 定</el-button>
  214. <el-button @click="cancel">取 消</el-button>
  215. </div>
  216. </el-dialog>
  217. </div>
  218. </template>
  219. <script>
  220. import { listWarehouse, getWarehouse, delWarehouse, addWarehouse,changeWareStatus, exportWarehouse,delCusCon,treeselect,updateWarehouse } from "@/api/basicdata/warehouse";
  221. import Treeselect from "@riophae/vue-treeselect";
  222. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  223. import {addUser, updateUser} from "@/api/system/user";
  224. export default {
  225. name: "Warehouse",
  226. components: {
  227. Treeselect
  228. },
  229. data() {
  230. return {
  231. fName:null,
  232. defaultProps: {
  233. children: "children",
  234. label: "label"
  235. },
  236. // 部门树选项
  237. deptOptions: undefined,
  238. // 从表
  239. contactList:[],
  240. // 遮罩层
  241. loading: true,
  242. // 选中数组
  243. ids: [],
  244. // 非单个禁用
  245. single: true,
  246. // 非多个禁用
  247. multiple: true,
  248. // 显示搜索条件
  249. showSearch: true,
  250. // 总条数
  251. total: 0,
  252. // 仓库表格数据
  253. warehouseList: [],
  254. // 状态数据字典
  255. statusOptions: [],
  256. // 弹出层标题
  257. title: "",
  258. // 是否显示弹出层
  259. open: false,
  260. // 查询参数
  261. queryParams: {
  262. pageNum: 1,
  263. pageSize: 10,
  264. fNo: null,
  265. fName: null,
  266. fAddr: null,
  267. fStatus: null,
  268. },
  269. formList:{
  270. },
  271. // 表单参数
  272. form: {
  273. },
  274. // 表单校验
  275. rules: {
  276. fNo: [
  277. { required: true, message: "编号不能为空", trigger: "blur" }
  278. ],
  279. fName: [
  280. { required: true, message: "名称不能为空", trigger: "blur" }
  281. ],
  282. fAddr: [
  283. { required: true, message: "地址不能为空", trigger: "blur" }
  284. ],
  285. fTotalgross: [
  286. { required: true, message: "库容不能为空", trigger: "blur" }
  287. ],
  288. }
  289. };
  290. },
  291. watch: {
  292. // 根据名称筛选部门树
  293. fName(val) {
  294. this.$refs.tree.filter(val);
  295. }
  296. },
  297. created() {
  298. this.getList();
  299. this.getTreeselect();
  300. this.getDicts("sys_normal_disable").then(response => {
  301. this.statusOptions = response.data;
  302. });
  303. },
  304. methods: {
  305. /** 查询部门下拉树结构 */
  306. getTreeselect() {
  307. treeselect().then(response => {
  308. this.deptOptions = response.data;
  309. });
  310. },
  311. // 筛选节点
  312. filterNode(value, data) {
  313. if (!value) return true;
  314. return data.label.indexOf(value) !== -1;
  315. },
  316. // 节点单击事件
  317. handleNodeClick(data) {
  318. this.queryParams.fWarehouseid = data.id;
  319. this.getList();
  320. },
  321. // 添加行
  322. addRow(tableData){
  323. var obj = {}
  324. tableData.push(obj)
  325. },
  326. //删除行
  327. deleteRow(index1,index, rows) {
  328. if(index!=null && index!=''){
  329. this.$confirm('是否确认删除', "警告", {
  330. confirmButtonText: "确定",
  331. cancelButtonText: "取消",
  332. type: "warning"
  333. }).then(function() {
  334. return delCusCon(index);
  335. }).then(() => {
  336. this.getList();
  337. this.msgSuccess("删除成功");
  338. rows.splice(index1, 1)
  339. })
  340. } else {
  341. rows.splice(index1, 1)
  342. }
  343. },
  344. /** 查询仓库列表 */
  345. getList() {
  346. this.loading = true;
  347. listWarehouse(this.queryParams).then(response => {
  348. this.warehouseList = response.rows;
  349. this.total = response.total;
  350. this.loading = false;
  351. });
  352. },
  353. // 取消按钮
  354. cancel() {
  355. this.open = false;
  356. this.reset();
  357. this.contList();
  358. },
  359. // 表单重置
  360. reset() {
  361. this.form = {
  362. fId: null,
  363. fNo: null,
  364. fName: null,
  365. fAddr: null,
  366. fStatus: "0",
  367. delFlag: null,
  368. createBy: null,
  369. createTime: null,
  370. updateBy: null,
  371. updateTime: null,
  372. remark: null,
  373. fCharg:'1',
  374. fContacts:null,
  375. fTel:null
  376. };
  377. this.resetForm("form");
  378. },
  379. // 从表重置
  380. contList() {
  381. this.contactList = []
  382. },
  383. // 状态修改
  384. handleStatusChange(row) {
  385. let text = row.fStatus === "0" ? "启用" : "停用";
  386. this.$confirm('确认要"' + text + '""' + row.fName + '"吗?', "警告", {
  387. confirmButtonText: "确定",
  388. cancelButtonText: "取消",
  389. type: "warning"
  390. }).then(function() {
  391. return changeWareStatus(row.fId, row.fStatus);
  392. }).then(() => {
  393. this.msgSuccess(text + "成功");
  394. }).catch(function() {
  395. row.fStatus = row.fStatus === "0" ? "1" : "0";
  396. });
  397. },
  398. /** 搜索按钮操作 */
  399. handleQuery() {
  400. this.queryParams.pageNum = 1;
  401. this.getList();
  402. },
  403. /** 重置按钮操作 */
  404. resetQuery() {
  405. this.resetForm("queryForm");
  406. this.handleQuery();
  407. },
  408. // 多选框选中数据
  409. handleSelectionChange(selection) {
  410. this.ids = selection.map(item => item.fId)
  411. this.single = selection.length!==1
  412. this.multiple = !selection.length
  413. },
  414. /** 新增按钮操作 */
  415. handleAdd() {
  416. this.reset();
  417. this.getTreeselect();
  418. this.contList();
  419. this.open = true;
  420. this.title = "添加仓库";
  421. },
  422. /** 修改按钮操作 */
  423. handleUpdate(row) {
  424. this.reset();
  425. this.getTreeselect();
  426. const fId = row.fId || this.ids
  427. getWarehouse(fId).then(response => {
  428. this.form = response.data;
  429. this.open = true;
  430. this.title = "修改仓库";
  431. })
  432. },
  433. /** 提交按钮 */
  434. submitForm() {
  435. this.$refs["form"].validate(valid => {
  436. if (valid) {
  437. if (this.form.fId != undefined) {
  438. updateWarehouse(this.form).then(response => {
  439. this.msgSuccess("修改成功");
  440. this.open = false;
  441. this.getList();
  442. });
  443. } else {
  444. addWarehouse(this.form).then(response => {
  445. this.msgSuccess("新增成功");
  446. this.open = false;
  447. this.getList();
  448. });
  449. }
  450. }
  451. });
  452. },
  453. /** 删除按钮操作 */
  454. handleDelete(row) {
  455. const fIds = row.fId || this.ids;
  456. this.$confirm('是否确认删除仓库编号为"' + fIds + '"的数据项?', "警告", {
  457. confirmButtonText: "确定",
  458. cancelButtonText: "取消",
  459. type: "warning"
  460. }).then(function() {
  461. return delWarehouse(fIds);
  462. }).then(() => {
  463. this.getList();
  464. this.msgSuccess("删除成功");
  465. })
  466. },
  467. /** 导出按钮操作 */
  468. handleExport() {
  469. const queryParams = this.queryParams;
  470. this.$confirm('是否确认导出所有仓库数据项?', "警告", {
  471. confirmButtonText: "确定",
  472. cancelButtonText: "取消",
  473. type: "warning"
  474. }).then(function() {
  475. return exportWarehouse(queryParams);
  476. }).then(response => {
  477. this.download(response.msg);
  478. })
  479. }
  480. }
  481. };
  482. </script>