index.vue 17 KB

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