index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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. }
  295. };
  296. },
  297. created() {
  298. this.getList();
  299. this.getDicts("sys_normal_disable").then(response => {
  300. this.statusOptions = response.data;
  301. });
  302. },
  303. methods: {
  304. // 添加行
  305. addRow(tableData){
  306. var obj = {}
  307. tableData.push(obj)
  308. },
  309. //删除行
  310. deleteRow(index1,index, rows) {
  311. if(index!=null && index!=''){
  312. this.$confirm('是否确认删除', "警告", {
  313. confirmButtonText: "确定",
  314. cancelButtonText: "取消",
  315. type: "warning"
  316. }).then(function() {
  317. return delCusCon(index);
  318. }).then(() => {
  319. this.getList();
  320. this.msgSuccess("删除成功");
  321. })
  322. } else {
  323. rows.splice(index1, 1)
  324. }
  325. },
  326. /** 查询仓库列表 */
  327. getList() {
  328. this.loading = true;
  329. listWarehouse(this.queryParams).then(response => {
  330. this.warehouseList = response.rows;
  331. this.total = response.total;
  332. this.loading = false;
  333. });
  334. },
  335. // 检验唯一
  336. testFno(){
  337. alert(1);
  338. },
  339. // 取消按钮
  340. cancel() {
  341. this.open = false;
  342. this.reset();
  343. this.contList();
  344. },
  345. // 表单重置
  346. reset() {
  347. this.form = {
  348. fId: null,
  349. fNo: null,
  350. fName: null,
  351. fAddr: null,
  352. fStatus: "0",
  353. delFlag: null,
  354. createBy: null,
  355. createTime: null,
  356. updateBy: null,
  357. updateTime: null,
  358. remark: null
  359. };
  360. this.resetForm("form");
  361. },
  362. // 从表重置
  363. contList() {
  364. this.contactList = []
  365. },
  366. // 状态修改
  367. handleStatusChange(row) {
  368. let text = row.fStatus === "0" ? "启用" : "停用";
  369. this.$confirm('确认要"' + text + '""' + row.fName + '"吗?', "警告", {
  370. confirmButtonText: "确定",
  371. cancelButtonText: "取消",
  372. type: "warning"
  373. }).then(function() {
  374. return changeWareStatus(row.fId, row.fStatus);
  375. }).then(() => {
  376. this.msgSuccess(text + "成功");
  377. }).catch(function() {
  378. row.fStatus = row.fStatus === "0" ? "1" : "0";
  379. });
  380. },
  381. /** 搜索按钮操作 */
  382. handleQuery() {
  383. this.queryParams.pageNum = 1;
  384. this.getList();
  385. },
  386. /** 重置按钮操作 */
  387. resetQuery() {
  388. this.resetForm("queryForm");
  389. this.handleQuery();
  390. },
  391. // 多选框选中数据
  392. handleSelectionChange(selection) {
  393. this.ids = selection.map(item => item.fId)
  394. this.single = selection.length!==1
  395. this.multiple = !selection.length
  396. },
  397. /** 新增按钮操作 */
  398. handleAdd() {
  399. this.reset();
  400. this.contList();
  401. this.open = true;
  402. this.title = "添加仓库";
  403. },
  404. /** 修改按钮操作 */
  405. handleUpdate(row) {
  406. this.reset();
  407. const fId = row.fId || this.ids
  408. getWarehouse(fId).then(response => {
  409. this.form = response.data['tWarehouse'];
  410. this.contactList= response.data['tWarehouseArea'];
  411. this.open = true;
  412. this.title = "修改仓库";
  413. });
  414. },
  415. /** 提交按钮 */
  416. submitForm() {
  417. this.$refs["form"].validate(valid => {
  418. if (this.contactList.length === 0) {
  419. this.msgError("库区为空");
  420. return
  421. }
  422. if (valid) {
  423. if (this.form.fId != null) {
  424. let formDate= new FormData()
  425. formDate.append('tWarehouse',JSON.stringify(this.form));
  426. formDate.append('tWarehouseArea',JSON.stringify(this.contactList));
  427. addWarehouse(formDate).then(response => {
  428. this.msgSuccess("修改成功");
  429. this.open = false;
  430. this.getList();
  431. });
  432. } else {
  433. let formDate= new FormData()
  434. formDate.append('tWarehouse',JSON.stringify(this.form));
  435. formDate.append('tWarehouseArea',JSON.stringify(this.contactList));
  436. addWarehouse(formDate).then(response => {
  437. this.msgSuccess("新增成功");
  438. this.open = false;
  439. this.getList();
  440. });
  441. }
  442. }
  443. });
  444. },
  445. /** 删除按钮操作 */
  446. handleDelete(row) {
  447. const fIds = row.fId || this.ids;
  448. this.$confirm('是否确认删除仓库编号为"' + fIds + '"的数据项?', "警告", {
  449. confirmButtonText: "确定",
  450. cancelButtonText: "取消",
  451. type: "warning"
  452. }).then(function() {
  453. return delWarehouse(fIds);
  454. }).then(() => {
  455. this.getList();
  456. this.msgSuccess("删除成功");
  457. })
  458. },
  459. /** 导出按钮操作 */
  460. handleExport() {
  461. const queryParams = this.queryParams;
  462. this.$confirm('是否确认导出所有仓库数据项?', "警告", {
  463. confirmButtonText: "确定",
  464. cancelButtonText: "取消",
  465. type: "warning"
  466. }).then(function() {
  467. return exportWarehouse(queryParams);
  468. }).then(response => {
  469. this.download(response.msg);
  470. })
  471. }
  472. }
  473. };
  474. </script>