index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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="warehouseName">
  5. <el-input
  6. v-model="queryParams.warehouseName"
  7. placeholder="请输入仓库名"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery" />
  11. </el-form-item>
  12. <el-form-item label="仓库编码" prop="warehouseCode">
  13. <el-input
  14. v-model="queryParams.warehouseCode"
  15. placeholder="请输入仓库编码"
  16. clearable
  17. size="small"
  18. @keyup.enter.native="handleQuery"/>
  19. </el-form-item>
  20. <el-form-item label="仓库类型" prop="warehouseType">
  21. <el-select v-model="queryParams.warehouseType" placeholder="请选择类型" clearable size="small">
  22. <el-option
  23. v-for="item in wareHouseTypeOptions"
  24. :key="item.dictValue"
  25. :label="item.dictLabel"
  26. :value="item.dictValue"/>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="联系人" prop="linkUsername">
  30. <el-input
  31. v-model="queryParams.linkUsername"
  32. placeholder="请输入联系人"
  33. clearable
  34. size="small"
  35. @keyup.enter.native="handleQuery"
  36. />
  37. </el-form-item>
  38. <el-form-item label="联系电话" prop="linkPhone">
  39. <el-input
  40. v-model="queryParams.linkPhone"
  41. placeholder="请输入联系电话"
  42. clearable
  43. size="small"
  44. @keyup.enter.native="handleQuery"
  45. />
  46. </el-form-item>
  47. <el-form-item label="状态" prop="status">
  48. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  49. <el-option
  50. v-for="item in statusOptions"
  51. :key="item.dictValue"
  52. :label="item.dictLabel"
  53. :value="item.dictValue"/>
  54. </el-select>
  55. </el-form-item>
  56. <!-- <el-form-item label="创建人ID" prop="createUserId">
  57. <el-input
  58. v-model="queryParams.createUserId"
  59. placeholder="请输入创建人ID"
  60. clearable
  61. size="small"
  62. @keyup.enter.native="handleQuery"
  63. />
  64. </el-form-item> -->
  65. <el-form-item>
  66. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  67. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  68. </el-form-item>
  69. </el-form>
  70. <el-row :gutter="10" class="mb8">
  71. <el-col :span="1.5">
  72. <el-button
  73. type="primary"
  74. icon="el-icon-plus"
  75. size="mini"
  76. @click="handleAdd"
  77. v-hasPermi="['oms:warehouse:add']"
  78. >新增</el-button>
  79. </el-col>
  80. <el-col :span="1.5">
  81. <el-button
  82. type="success"
  83. icon="el-icon-edit"
  84. size="mini"
  85. :disabled="single"
  86. @click="handleUpdate"
  87. v-hasPermi="['oms:warehouse:edit']"
  88. >修改</el-button>
  89. </el-col>
  90. <el-col :span="1.5">
  91. <el-button
  92. type="danger"
  93. icon="el-icon-delete"
  94. size="mini"
  95. :disabled="multiple"
  96. @click="handleDelete"
  97. v-hasPermi="['oms:warehouse:delete']"
  98. >删除</el-button>
  99. </el-col>
  100. <el-col :span="1.5">
  101. <el-button
  102. type="warning"
  103. icon="el-icon-download"
  104. size="mini"
  105. @click="handleExport"
  106. v-hasPermi="['oms:warehouse:export']"
  107. >导出</el-button>
  108. </el-col>
  109. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  110. </el-row>
  111. <el-table v-loading="loading" :data="warehouseList" @selection-change="handleSelectionChange">
  112. <el-table-column type="selection" width="55" align="center" />
  113. <el-table-column label="ID" width="55" align="center" prop="warehouseId" />
  114. <el-table-column label="仓库名" align="center" prop="warehouseName" />
  115. <el-table-column label="仓库编码" width="120" align="center" prop="warehouseCode" />
  116. <el-table-column label="仓库类型" align="center" prop="warehouseType">
  117. <template slot-scope="scope">
  118. <el-tag prop="warehouseType" v-for="(item, index) in wareHouseTypeOptions" v-if="scope.row.warehouseType==item.dictValue">{{item.dictLabel}}</el-tag>
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="联系人" align="center" prop="linkUsername" />
  122. <el-table-column label="联系电话" align="center" prop="linkPhone" />
  123. <el-table-column width="100" label="所属省市区" align="center" prop="cityIds" />
  124. <el-table-column label="地址" align="center" prop="address" />
  125. <el-table-column label="分配比例" align="center" prop="rate">
  126. <template slot-scope="scope">
  127. {{ !!scope.row.rate?parseInt(scope.row.rate*100)+"%":"0%"}}
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="状态" align="center" prop="status">
  131. <template slot-scope="scope">
  132. <el-tag prop="status" v-for="(item, index) in statusOptions" v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="创建人" align="center" prop="createUserName" />
  136. <el-table-column width="100" label="创建时间" align="center" prop="createTime" />
  137. <el-table-column label="备注" align="center" prop="remark" />
  138. <el-table-column width="120" label="操作" align="center" class-name="small-padding fixed-width">
  139. <template slot-scope="scope">
  140. <el-button
  141. size="mini"
  142. type="text"
  143. icon="el-icon-edit"
  144. @click="handleUpdate(scope.row)"
  145. v-hasPermi="['oms:warehouse:edit']"
  146. >修改</el-button>
  147. <el-button
  148. size="mini"
  149. type="text"
  150. icon="el-icon-delete"
  151. @click="handleDelete(scope.row)"
  152. v-hasPermi="['oms:warehouse:delete']"
  153. >删除</el-button>
  154. </template>
  155. </el-table-column>
  156. </el-table>
  157. <pagination
  158. v-show="total>0"
  159. :total="total"
  160. :page.sync="queryParams.pageNum"
  161. :limit.sync="queryParams.pageSize"
  162. @pagination="getList"
  163. />
  164. <!-- 添加或修改仓库对话框 -->
  165. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  166. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  167. <el-form-item label="仓库名称" prop="warehouseName">
  168. <el-input v-model="form.warehouseName" placeholder="请输入仓库名" />
  169. </el-form-item>
  170. <el-form-item label="仓库类型" prop="warehouseType">
  171. <el-select v-model="form.warehouseType" placeholder="请选择状态" clearable size="small">
  172. <el-option
  173. v-for="item in wareHouseTypeOptions"
  174. :key="item.dictValue"
  175. :label="item.dictLabel"
  176. :value="item.dictValue"
  177. />
  178. </el-select>
  179. </el-form-item>
  180. <el-form-item label="分配比例" prop="rate">
  181. <el-input v-model="form.rate" placeholder="请输入仓库分配比例" >
  182. <template slot="append">%</template>
  183. </el-input>
  184. </el-form-item>
  185. <el-form-item label="联系人" prop="linkUsername">
  186. <el-input v-model="form.linkUsername" placeholder="请输入联系人" />
  187. </el-form-item>
  188. <el-form-item label="联系电话" prop="linkPhone">
  189. <el-input v-model="form.linkPhone" placeholder="请输入联系电话" />
  190. </el-form-item>
  191. <el-form-item label="所在城市" prop="cityIds">
  192. <el-cascader
  193. ref="citySelect"
  194. v-model="cityIds"
  195. :options="citys"
  196. @change="handleCityChange"></el-cascader>
  197. </el-form-item>
  198. <el-form-item label="地址" prop="address">
  199. <el-input v-model="form.address" placeholder="请输入地址" />
  200. </el-form-item>
  201. <el-form-item label="备注" prop="remark">
  202. <el-input v-model="form.remark" placeholder="请输入备注" />
  203. </el-form-item>
  204. <el-form-item label="状态" prop="status">
  205. <el-select v-model="form.status" placeholder="请选择状态" clearable size="small">
  206. <el-option
  207. v-for="item in statusOptions"
  208. :key="item.dictValue"
  209. :label="item.dictLabel"
  210. :value="item.dictValue"
  211. />
  212. </el-select>
  213. </el-form-item>
  214. </el-form>
  215. <div slot="footer" class="dialog-footer">
  216. <el-button type="primary" @click="submitForm">确 定</el-button>
  217. <el-button @click="cancel">取 消</el-button>
  218. </div>
  219. </el-dialog>
  220. </div>
  221. </template>
  222. <script>
  223. import { wlistWarehouse, getWarehouse, delWarehouse, addWarehouse, updateWarehouse, exportWarehouse } from "@/api/oms/warehouse";
  224. import {getCitys} from "@/api/store/city";
  225. export default {
  226. name: "Warehouse",
  227. data() {
  228. return {
  229. // 遮罩层
  230. loading: true,
  231. // 选中数组
  232. ids: [],
  233. // 非单个禁用
  234. single: true,
  235. // 非多个禁用
  236. multiple: true,
  237. // 显示搜索条件
  238. showSearch: true,
  239. // 总条数
  240. total: 0,
  241. // 仓库表格数据
  242. warehouseList: [],
  243. wareHouseTypeOptions:[],
  244. statusOptions:[],
  245. // 弹出层标题
  246. title: "",
  247. // 是否显示弹出层
  248. open: false,
  249. cityIds:[],
  250. citys:[],
  251. // 查询参数
  252. queryParams: {
  253. pageNum: 1,
  254. pageSize: 10,
  255. warehouseName: null,
  256. warehouseCode: null,
  257. warehouseType: null,
  258. linkUsername: null,
  259. linkPhone: null,
  260. cityIds: null,
  261. address: null,
  262. status: null,
  263. createUserId: null,
  264. },
  265. // 表单参数
  266. form: {},
  267. // 表单校验
  268. rules: {
  269. warehouseName: [
  270. { required: true, message: "仓库名称不能为空", trigger: "blur" }
  271. ],
  272. linkUsername: [
  273. { required: true, message: "联系人不能为空", trigger: "blur" }
  274. ],
  275. // cityIds: [
  276. // { required: true, message: "所在城市不能为空", trigger: "blur" }
  277. // ],
  278. }
  279. };
  280. },
  281. created() {
  282. this.getDicts("oms_warehouse_type").then((response) => {
  283. this.wareHouseTypeOptions = response.data.filter(item => {
  284. return parseInt(item.dictValue)<=2
  285. });
  286. });
  287. this.getDicts("oms_warehouse_status").then((response) => {
  288. this.statusOptions = response.data;
  289. });
  290. this.getCitys();
  291. this.getList();
  292. },
  293. methods: {
  294. /** 查询仓库列表 */
  295. getList() {
  296. this.loading = true;
  297. wlistWarehouse(this.queryParams).then(response => {
  298. this.warehouseList = response.rows;
  299. this.total = response.total;
  300. this.loading = false;
  301. });
  302. },
  303. // 取消按钮
  304. cancel() {
  305. this.open = false;
  306. this.reset();
  307. },
  308. // 表单重置
  309. reset() {
  310. this.form = {
  311. warehouseId: null,
  312. warehouseName: null,
  313. warehouseCode: null,
  314. warehouseType: null,
  315. linkUsername: null,
  316. linkPhone: null,
  317. cityIds: null,
  318. address: null,
  319. remark: null,
  320. rate:null,
  321. status: '0',
  322. createUserId: null,
  323. createTime: null,
  324. updateTime: null
  325. };
  326. this.resetForm("form");
  327. },
  328. /** 搜索按钮操作 */
  329. handleQuery() {
  330. this.queryParams.pageNum = 1;
  331. this.getList();
  332. },
  333. /** 重置按钮操作 */
  334. resetQuery() {
  335. this.resetForm("queryForm");
  336. this.handleQuery();
  337. },
  338. // 多选框选中数据
  339. handleSelectionChange(selection) {
  340. this.ids = selection.map(item => item.warehouseId)
  341. this.single = selection.length!==1
  342. this.multiple = !selection.length
  343. },
  344. /** 新增按钮操作 */
  345. handleAdd() {
  346. this.reset();
  347. this.open = true;
  348. this.title = "添加仓库";
  349. },
  350. /** 修改按钮操作 */
  351. handleUpdate(row) {
  352. this.reset();
  353. const warehouseId = row.warehouseId || this.ids
  354. getWarehouse(warehouseId).then(response => {
  355. this.form = response.data;
  356. if(this.form.warehouseType!=null){
  357. this.form.warehouseType = this.form.warehouseType.toString();
  358. }
  359. if(this.form.status!=null){
  360. this.form.status = this.form.status.toString();
  361. }
  362. if(!!this.form.rate){
  363. this.form.rate = this.form.rate*100;
  364. }
  365. this.open = true;
  366. this.title = "修改仓库";
  367. });
  368. },
  369. getCitys(){
  370. getCitys().then(res => {
  371. this.loading = false;
  372. this.citys=res.data;
  373. });
  374. },
  375. /** 提交按钮 */
  376. submitForm() {
  377. this.$refs["form"].validate(valid => {
  378. if (valid) {
  379. if (this.form.warehouseId != null) {
  380. updateWarehouse(this.form).then(response => {
  381. if (response.code === 200) {
  382. this.msgSuccess("修改成功");
  383. this.open = false;
  384. this.getList();
  385. }
  386. });
  387. } else {
  388. addWarehouse(this.form).then(response => {
  389. if (response.code === 200) {
  390. this.msgSuccess("新增成功");
  391. this.open = false;
  392. this.getList();
  393. }
  394. });
  395. }
  396. }
  397. });
  398. },
  399. /** 删除按钮操作 */
  400. handleDelete(row) {
  401. const warehouseIds = row.warehouseId || this.ids;
  402. this.$confirm('是否确认删除仓库编号为"' + warehouseIds + '"的数据项?', "警告", {
  403. confirmButtonText: "确定",
  404. cancelButtonText: "取消",
  405. type: "warning"
  406. }).then(function() {
  407. return delWarehouse(warehouseIds);
  408. }).then(() => {
  409. this.getList();
  410. this.msgSuccess("删除成功");
  411. }).catch(function() {});
  412. },
  413. /** 导出按钮操作 */
  414. handleExport() {
  415. const queryParams = this.queryParams;
  416. this.$confirm('是否确认导出所有仓库数据项?', "警告", {
  417. confirmButtonText: "确定",
  418. cancelButtonText: "取消",
  419. type: "warning"
  420. }).then(function() {
  421. return exportWarehouse(queryParams);
  422. }).then(response => {
  423. this.download(response.msg);
  424. }).catch(function() {});
  425. },
  426. handleCityChange(value) {
  427. console.log(value);
  428. var nodes=this.$refs.citySelect.getCheckedNodes();
  429. this.form.cityIds=nodes[0].pathLabels[0]+"-"+nodes[0].pathLabels[1]+"-"+nodes[0].pathLabels[2];
  430. this.form.cityIdsStr=value.toString();
  431. console.log(this.form.cityIdsStr);
  432. },
  433. getCitys(){
  434. getCitys().then(res => {
  435. this.loading = false;
  436. this.citys=res.data;
  437. });
  438. },
  439. }
  440. };
  441. </script>