index.vue 15 KB

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