index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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="状态,默认 T ,正常T 停用F 下拉选择" align="center" prop="fId" />-->
  100. <el-table-column label="编号" align="center" prop="fNo" />
  101. <el-table-column label="名称" align="center" prop="fName" />
  102. <el-table-column label="地址" align="center" prop="fAddr" />
  103. <!--<el-table-column label="状态,默认 T ,正常T 停用F 下拉选择" align="center" prop="fStatus" />-->
  104. <el-table-column label="状态" align="center">
  105. <template slot-scope="scope">
  106. <el-switch
  107. v-model="scope.row.fStatus"
  108. active-value="0"
  109. inactive-value="1"
  110. @change="handleStatusChange(scope.row)"
  111. ></el-switch>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="备注" align="center" prop="remark" />
  115. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  116. <template slot-scope="scope">
  117. <el-button
  118. size="mini"
  119. type="text"
  120. icon="el-icon-edit"
  121. @click="handleUpdate(scope.row)"
  122. v-hasPermi="['basicdata:warehouse:edit']"
  123. >修改</el-button>
  124. <el-button
  125. size="mini"
  126. type="text"
  127. icon="el-icon-delete"
  128. @click="handleDelete(scope.row)"
  129. v-hasPermi="['basicdata:warehouse:remove']"
  130. >删除</el-button>
  131. </template>
  132. </el-table-column>
  133. </el-table>
  134. <pagination
  135. v-show="total>0"
  136. :total="total"
  137. :page.sync="queryParams.pageNum"
  138. :limit.sync="queryParams.pageSize"
  139. @pagination="getList"
  140. />
  141. <!-- 添加或修改仓库对话框 -->
  142. <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="500px" append-to-body>
  143. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  144. <el-row>
  145. <el-col :span="12">
  146. <el-form-item label="编号" prop="fNo">
  147. <el-input v-model="form.fNo" placeholder="请输入编号" />
  148. </el-form-item>
  149. </el-col>
  150. <el-col :span="12">
  151. <el-form-item label="名称" prop="fName">
  152. <el-input v-model="form.fName" placeholder="请输入名称" />
  153. </el-form-item>
  154. </el-col>
  155. </el-row>
  156. <el-row>
  157. <el-col :span="12">
  158. <el-form-item label="地址" prop="fAddr">
  159. <el-input v-model="form.fAddr" placeholder="请输入地址" />
  160. </el-form-item>
  161. </el-col>
  162. <el-col :span="12">
  163. <el-form-item label="状态">
  164. <el-radio-group v-model="form.fStatus">
  165. <el-radio
  166. v-for="dict in statusOptions"
  167. :key="dict.dictValue"
  168. :label="dict.dictValue"
  169. >{{dict.dictLabel}}</el-radio>
  170. </el-radio-group>
  171. </el-form-item>
  172. </el-col>
  173. </el-row>
  174. <!--<el-form-item label="状态,默认 T ,正常T 停用F 下拉选择">
  175. <el-radio-group v-model="form.fStatus">
  176. <el-radio label="1">请选择字典生成</el-radio>
  177. </el-radio-group>
  178. </el-form-item>-->
  179. <!--<el-form-item label="删除状态" prop="delFlag">
  180. <el-input v-model="form.delFlag" placeholder="请输入删除状态" />
  181. </el-form-item>-->
  182. <el-form-item label="备注" prop="remark">
  183. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  184. </el-form-item>
  185. </el-form>
  186. <div slot="footer" class="dialog-footer">
  187. <el-button type="primary" @click="submitForm">确 定</el-button>
  188. <el-button @click="cancel">取 消</el-button>
  189. </div>
  190. </el-dialog>
  191. </div>
  192. </template>
  193. <script>
  194. import { listWarehouse, getWarehouse, delWarehouse, addWarehouse, updateWarehouse,changeWareStatus, exportWarehouse } from "../../../api/basicdata/warehouse";
  195. export default {
  196. name: "Warehouse",
  197. components: {
  198. },
  199. data() {
  200. return {
  201. // 遮罩层
  202. loading: true,
  203. // 选中数组
  204. ids: [],
  205. // 非单个禁用
  206. single: true,
  207. // 非多个禁用
  208. multiple: true,
  209. // 显示搜索条件
  210. showSearch: true,
  211. // 总条数
  212. total: 0,
  213. // 仓库表格数据
  214. warehouseList: [],
  215. // 状态数据字典
  216. statusOptions: [],
  217. // 弹出层标题
  218. title: "",
  219. // 是否显示弹出层
  220. open: false,
  221. // 查询参数
  222. queryParams: {
  223. pageNum: 1,
  224. pageSize: 10,
  225. fNo: null,
  226. fName: null,
  227. fAddr: null,
  228. fStatus: null,
  229. },
  230. // 表单参数
  231. form: {},
  232. // 表单校验
  233. rules: {
  234. fNo: [
  235. { required: true, message: "编号不能为空", trigger: "blur" }
  236. ],
  237. fName: [
  238. { required: true, message: "名称不能为空", trigger: "blur" }
  239. ],
  240. fAddr: [
  241. { required: true, message: "地址不能为空", trigger: "blur" }
  242. ],
  243. }
  244. };
  245. },
  246. created() {
  247. this.getList();
  248. this.getDicts("sys_normal_disable").then(response => {
  249. this.statusOptions = response.data;
  250. });
  251. },
  252. methods: {
  253. /** 查询仓库列表 */
  254. getList() {
  255. this.loading = true;
  256. listWarehouse(this.queryParams).then(response => {
  257. this.warehouseList = response.rows;
  258. this.total = response.total;
  259. this.loading = false;
  260. });
  261. },
  262. // 取消按钮
  263. cancel() {
  264. this.open = false;
  265. this.reset();
  266. },
  267. // 表单重置
  268. reset() {
  269. this.form = {
  270. fId: null,
  271. fNo: null,
  272. fName: null,
  273. fAddr: null,
  274. fStatus: "0",
  275. delFlag: null,
  276. createBy: null,
  277. createTime: null,
  278. updateBy: null,
  279. updateTime: null,
  280. remark: null
  281. };
  282. this.resetForm("form");
  283. },
  284. // 状态修改
  285. handleStatusChange(row) {
  286. let text = row.fStatus === "0" ? "启用" : "停用";
  287. this.$confirm('确认要"' + text + '""' + row.fName + '"吗?', "警告", {
  288. confirmButtonText: "确定",
  289. cancelButtonText: "取消",
  290. type: "warning"
  291. }).then(function() {
  292. return changeWareStatus(row.fId, row.fStatus);
  293. }).then(() => {
  294. this.msgSuccess(text + "成功");
  295. }).catch(function() {
  296. row.fStatus = row.fStatus === "0" ? "1" : "0";
  297. });
  298. },
  299. /** 搜索按钮操作 */
  300. handleQuery() {
  301. this.queryParams.pageNum = 1;
  302. this.getList();
  303. },
  304. /** 重置按钮操作 */
  305. resetQuery() {
  306. this.resetForm("queryForm");
  307. this.handleQuery();
  308. },
  309. // 多选框选中数据
  310. handleSelectionChange(selection) {
  311. this.ids = selection.map(item => item.fId)
  312. this.single = selection.length!==1
  313. this.multiple = !selection.length
  314. },
  315. /** 新增按钮操作 */
  316. handleAdd() {
  317. this.reset();
  318. this.open = true;
  319. this.title = "添加仓库";
  320. },
  321. /** 修改按钮操作 */
  322. handleUpdate(row) {
  323. this.reset();
  324. const fId = row.fId || this.ids
  325. getWarehouse(fId).then(response => {
  326. this.form = response.data;
  327. this.open = true;
  328. this.title = "修改仓库";
  329. });
  330. },
  331. /** 提交按钮 */
  332. submitForm() {
  333. this.$refs["form"].validate(valid => {
  334. if (valid) {
  335. if (this.form.fId != null) {
  336. updateWarehouse(this.form).then(response => {
  337. this.msgSuccess("修改成功");
  338. this.open = false;
  339. this.getList();
  340. });
  341. } else {
  342. addWarehouse(this.form).then(response => {
  343. this.msgSuccess("新增成功");
  344. this.open = false;
  345. this.getList();
  346. });
  347. }
  348. }
  349. });
  350. },
  351. /** 删除按钮操作 */
  352. handleDelete(row) {
  353. const fIds = row.fId || this.ids;
  354. this.$confirm('是否确认删除仓库编号为"' + fIds + '"的数据项?', "警告", {
  355. confirmButtonText: "确定",
  356. cancelButtonText: "取消",
  357. type: "warning"
  358. }).then(function() {
  359. return delWarehouse(fIds);
  360. }).then(() => {
  361. this.getList();
  362. this.msgSuccess("删除成功");
  363. })
  364. },
  365. /** 导出按钮操作 */
  366. handleExport() {
  367. const queryParams = this.queryParams;
  368. this.$confirm('是否确认导出所有仓库数据项?', "警告", {
  369. confirmButtonText: "确定",
  370. cancelButtonText: "取消",
  371. type: "warning"
  372. }).then(function() {
  373. return exportWarehouse(queryParams);
  374. }).then(response => {
  375. this.download(response.msg);
  376. })
  377. }
  378. }
  379. };
  380. </script>