index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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="500px" append-to-body>
  141. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  142. <el-row>
  143. <el-col :span="12">
  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="12">
  149. <el-form-item label="名称" prop="fName">
  150. <el-input v-model="form.fName" placeholder="请输入名称" />
  151. </el-form-item>
  152. </el-col>
  153. </el-row>
  154. <el-row>
  155. <el-col :span="12">
  156. <el-form-item label="地址" prop="fAddr">
  157. <el-input v-model="form.fAddr" placeholder="请输入地址" />
  158. </el-form-item>
  159. </el-col>
  160. <el-col :span="12">
  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-row>
  172. <!--<el-form-item label="状态,默认 T ,正常T 停用F 下拉选择">
  173. <el-radio-group v-model="form.fStatus">
  174. <el-radio label="1">请选择字典生成</el-radio>
  175. </el-radio-group>
  176. </el-form-item>-->
  177. <!--<el-form-item label="删除状态" prop="delFlag">
  178. <el-input v-model="form.delFlag" placeholder="请输入删除状态" />
  179. </el-form-item>-->
  180. <el-form-item label="备注" prop="remark">
  181. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  182. </el-form-item>
  183. <div >
  184. <el-row :gutter="10" class="mb8">
  185. <el-col :span="1.5">
  186. <el-button
  187. type="primary"
  188. icon="el-icon-plus"
  189. size="mini"
  190. @click="addRow(contactList)"
  191. >添加</el-button>
  192. </el-col>
  193. </el-row>
  194. </div>
  195. <el-table v-loading="loading" :data="contactList" @selection-change="handleSelectionChange">
  196. <el-table-column type="index" label="序号" align="center"/>
  197. <el-table-column label="库区编号" align="center" prop="fNo" >
  198. <template scope="scope">
  199. <el-input v-model="scope.row.fNo" placeholder="库区编号" />
  200. </template>
  201. </el-table-column>
  202. <el-table-column label="库区名称" align="center" prop="fName" >
  203. <template scope="scope">
  204. <el-input v-model="scope.row.fName" placeholder="库区名称" />
  205. </template>
  206. </el-table-column>
  207. <el-table-column label="备注" align="center" prop="remark" >
  208. <template scope="scope">
  209. <el-input v-model="scope.row.remark" placeholder="备注" />
  210. </template>
  211. </el-table-column>
  212. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">
  213. <template slot-scope="scope">
  214. <el-button
  215. size="mini"
  216. type="text"
  217. icon="el-icon-delete"
  218. @click.native.prevent="deleteRow(scope.$index,scope.row.tId, contactList)"
  219. v-hasPermi="['basicdata:contact:edit']"
  220. >删除</el-button>
  221. </template>
  222. </el-table-column>
  223. </el-table>
  224. </el-form>
  225. <div slot="footer" class="dialog-footer">
  226. <el-button type="primary" @click="submitForm">确 定</el-button>
  227. <el-button @click="cancel">取 消</el-button>
  228. </div>
  229. </el-dialog>
  230. </div>
  231. </template>
  232. <script>
  233. import { listWarehouse, getWarehouse, delWarehouse, addWarehouse, updateWarehouse,changeWareStatus, exportWarehouse } from "../../../api/basicdata/warehouse";
  234. export default {
  235. name: "Warehouse",
  236. components: {
  237. },
  238. data() {
  239. return {
  240. // 从表
  241. contactList:[],
  242. // 遮罩层
  243. loading: true,
  244. // 选中数组
  245. ids: [],
  246. // 非单个禁用
  247. single: true,
  248. // 非多个禁用
  249. multiple: true,
  250. // 显示搜索条件
  251. showSearch: true,
  252. // 总条数
  253. total: 0,
  254. // 仓库表格数据
  255. warehouseList: [],
  256. // 状态数据字典
  257. statusOptions: [],
  258. // 弹出层标题
  259. title: "",
  260. // 是否显示弹出层
  261. open: false,
  262. // 查询参数
  263. queryParams: {
  264. pageNum: 1,
  265. pageSize: 10,
  266. fNo: null,
  267. fName: null,
  268. fAddr: null,
  269. fStatus: null,
  270. },
  271. // 表单参数
  272. form: {},
  273. // 表单校验
  274. rules: {
  275. fNo: [
  276. { required: true, message: "编号不能为空", trigger: "blur" }
  277. ],
  278. fName: [
  279. { required: true, message: "名称不能为空", trigger: "blur" }
  280. ],
  281. fAddr: [
  282. { required: true, message: "地址不能为空", trigger: "blur" }
  283. ],
  284. }
  285. };
  286. },
  287. created() {
  288. this.getList();
  289. this.getDicts("sys_normal_disable").then(response => {
  290. this.statusOptions = response.data;
  291. });
  292. },
  293. methods: {
  294. // 添加行
  295. addRow(tableData){
  296. var obj = {}
  297. tableData.push(obj)
  298. },
  299. //删除行
  300. deleteRow(index1,index, rows) {
  301. if(index!=null && index!=''){
  302. this.$confirm('是否确认删除', "警告", {
  303. confirmButtonText: "确定",
  304. cancelButtonText: "取消",
  305. type: "warning"
  306. }).then(function() {
  307. alert(index);
  308. return delCusCon(index);
  309. }).then(() => {
  310. this.getList();
  311. this.msgSuccess("删除成功");
  312. })
  313. } else {
  314. rows.splice(index1, 1)
  315. }
  316. },
  317. /** 查询仓库列表 */
  318. getList() {
  319. this.loading = true;
  320. listWarehouse(this.queryParams).then(response => {
  321. this.warehouseList = response.rows;
  322. this.total = response.total;
  323. this.loading = false;
  324. });
  325. },
  326. // 检验唯一
  327. testFno(){
  328. alert(1);
  329. },
  330. // 取消按钮
  331. cancel() {
  332. this.open = false;
  333. this.reset();
  334. this.contList();
  335. },
  336. // 表单重置
  337. reset() {
  338. this.form = {
  339. fId: null,
  340. fNo: null,
  341. fName: null,
  342. fAddr: null,
  343. fStatus: "0",
  344. delFlag: null,
  345. createBy: null,
  346. createTime: null,
  347. updateBy: null,
  348. updateTime: null,
  349. remark: null
  350. };
  351. this.resetForm("form");
  352. },
  353. // 从表重置
  354. contList() {
  355. this.contactList = []
  356. },
  357. // 状态修改
  358. handleStatusChange(row) {
  359. let text = row.fStatus === "0" ? "启用" : "停用";
  360. this.$confirm('确认要"' + text + '""' + row.fName + '"吗?', "警告", {
  361. confirmButtonText: "确定",
  362. cancelButtonText: "取消",
  363. type: "warning"
  364. }).then(function() {
  365. return changeWareStatus(row.fId, row.fStatus);
  366. }).then(() => {
  367. this.msgSuccess(text + "成功");
  368. }).catch(function() {
  369. row.fStatus = row.fStatus === "0" ? "1" : "0";
  370. });
  371. },
  372. /** 搜索按钮操作 */
  373. handleQuery() {
  374. this.queryParams.pageNum = 1;
  375. this.getList();
  376. },
  377. /** 重置按钮操作 */
  378. resetQuery() {
  379. this.resetForm("queryForm");
  380. this.handleQuery();
  381. },
  382. // 多选框选中数据
  383. handleSelectionChange(selection) {
  384. this.ids = selection.map(item => item.fId)
  385. this.single = selection.length!==1
  386. this.multiple = !selection.length
  387. },
  388. /** 新增按钮操作 */
  389. handleAdd() {
  390. this.reset();
  391. this.contList();
  392. this.open = true;
  393. this.title = "添加仓库";
  394. },
  395. /** 修改按钮操作 */
  396. handleUpdate(row) {
  397. this.reset();
  398. const fId = row.fId || this.ids
  399. getWarehouse(fId).then(response => {
  400. this.form = response.data['tWarehouse'];
  401. this.contactList= response.data['tWarehouseArea'];
  402. this.open = true;
  403. this.title = "修改仓库";
  404. });
  405. },
  406. /** 提交按钮 */
  407. submitForm() {
  408. this.$refs["form"].validate(valid => {
  409. if (this.contactList.length === 0) {
  410. this.msgError("库区为空");
  411. return
  412. }
  413. if (valid) {
  414. if (this.form.fId != null) {
  415. let formDate= new FormData()
  416. formDate.append('tWarehouse',JSON.stringify(this.form));
  417. formDate.append('tWarehouseArea',JSON.stringify(this.contactList));
  418. addWarehouse(formDate).then(response => {
  419. this.msgSuccess("修改成功");
  420. this.open = false;
  421. this.getList();
  422. });
  423. } else {
  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. }
  433. }
  434. });
  435. },
  436. /** 删除按钮操作 */
  437. handleDelete(row) {
  438. const fIds = row.fId || this.ids;
  439. this.$confirm('是否确认删除仓库编号为"' + fIds + '"的数据项?', "警告", {
  440. confirmButtonText: "确定",
  441. cancelButtonText: "取消",
  442. type: "warning"
  443. }).then(function() {
  444. return delWarehouse(fIds);
  445. }).then(() => {
  446. this.getList();
  447. this.msgSuccess("删除成功");
  448. })
  449. },
  450. /** 导出按钮操作 */
  451. handleExport() {
  452. const queryParams = this.queryParams;
  453. this.$confirm('是否确认导出所有仓库数据项?', "警告", {
  454. confirmButtonText: "确定",
  455. cancelButtonText: "取消",
  456. type: "warning"
  457. }).then(function() {
  458. return exportWarehouse(queryParams);
  459. }).then(response => {
  460. this.download(response.msg);
  461. })
  462. }
  463. }
  464. };
  465. </script>