index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <el-row>
  5. <el-col :span="4">
  6. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" style="height:82vh;">
  7. <template slot="addBtn">
  8. <el-tooltip class="item" effect="dark" content="新建分类" placement="top">
  9. <i class="el-icon-setting" @click="goodsTypeVisible = true"
  10. style="font-size:18px;line-height: 1px;width: 20px;padding:10px;"></i>
  11. </el-tooltip>
  12. </template>
  13. </avue-tree>
  14. </el-col>
  15. <el-col :span="20">
  16. <avue-crud ref="crud" :option="option" :data="dataList" :page.sync="page" :search.sync="search" :key="key"
  17. @search-change="searchChange" @current-change="currentChange" @size-change="sizeChange"
  18. @refresh-change="refreshChange" @on-load="onLoad" :table-loading="loading" @saveColumn="saveColumn"
  19. @resetColumn="resetColumn" :cell-style="cellStyle" @search-criteria-switch="searchCriteriaSwitch">
  20. <template slot="menuLeft">
  21. <el-button type="primary" size="mini" @click.stop="newAdd()">新建产品
  22. </el-button>
  23. <el-button type="primary" size="mini" icon="el-icon-bottom" @click="excelBox = true">导入
  24. </el-button>
  25. <el-button type="primary" size="mini" icon="el-icon-top" @click="outExport">导出
  26. </el-button>
  27. </template>
  28. <template slot="enableOrNot" slot-scope="{row,index,disabled}">
  29. <div v-if="row.enableOrNot === 1">是</div>
  30. <div v-else style="color: red">否</div>
  31. </template>
  32. <template slot-scope="{ row, index }" slot="cname">
  33. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 2)">{{ row.cname }}
  34. </span>
  35. </template>
  36. <template slot-scope="{ row, index }" slot="menu">
  37. <!-- <el-button :size="small" :type="text"
  38. @click.stop="rowDel(row, index)" v-if="row.status != 0">删除</el-button> -->
  39. <!-- <el-tooltip class="item" effect="dark" content="删除" placement="top">
  40. <i class="tradingIcon icon-del" />
  41. </el-tooltip> -->
  42. <!-- <el-tooltip class="item" effect="dark" content="新建销售订单" placement="top">
  43. <i class="tradingIcon icon-add" />
  44. </el-tooltip>
  45. <el-tooltip class="item" effect="dark" content="编辑" placement="top">
  46. <i class="tradingIcon icon-edit" />
  47. </el-tooltip>
  48. <el-tooltip class="item" effect="dark" content="收款" placement="top">
  49. <i class="tradingIcon icon-proceeds" />
  50. </el-tooltip>
  51. <el-tooltip class="item" effect="dark" content="发货" placement="top">
  52. <i class="tradingIcon icon-deliver" />
  53. </el-tooltip>
  54. <el-tooltip class="item" effect="dark" content="对账" placement="top">
  55. <i class="tradingIcon icon-reconciliation" />
  56. </el-tooltip> -->
  57. <!-- <el-button type="text" size="small" @click.stop="editOpen(row, 2)">
  58. 查看
  59. </el-button>
  60. <el-button type="text" size="small" @click.stop="rowDel(row, index)">
  61. 删除
  62. </el-button> -->
  63. <el-button type="text" size="small" @click.stop="rowDel(row, index)" v-if="row.status != 0" :disabled="row.enableOrNot">
  64. 删除
  65. </el-button>
  66. </template>
  67. </avue-crud>
  68. </el-col>
  69. </el-row>
  70. </basic-container>
  71. <details-page v-if="!show" @goBack="goBack()" :detailData="detailData" />
  72. <el-dialog title="设置产品分类" v-dialogDrag :visible.sync="goodsTypeVisible" class="avue-dialog" width="80%" append-to-body
  73. @closed="goodsTypeClosed">
  74. <span>
  75. <!--<goods-type></goods-type>-->
  76. <corp-type></corp-type>
  77. <!-- <avue-form :key="reload" ref="goodsType" v-model="form2" :option="option2" style="margin-top:20px">
  78. </avue-form> -->
  79. </span>
  80. <div class="avue-dialog__footer">
  81. <el-button @click="goodsTypeVisible = false" size="mini">取 消</el-button>
  82. <el-button @click="saveGoodstype" type="primary" size="mini">确 定</el-button>
  83. </div>
  84. </el-dialog>
  85. <el-dialog title="添加产品" append-to-body :visible.sync="excelBox" :close-on-click-modal="false" width="555px">
  86. <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
  87. <template slot="excelTemplate">
  88. <el-button type="primary" @click="derivation">
  89. 点击下载<i class="el-icon-download el-icon--right"></i>
  90. </el-button>
  91. </template>
  92. </avue-form>
  93. <p style="text-align: center;color: #DC0505">
  94. 温馨提示 第一次导入时请先下载模板
  95. </p>
  96. </el-dialog>
  97. </div>
  98. </template>
  99. <script>
  100. import detailsPage from "./detailsPage";
  101. import { option } from "./js/optionList";
  102. import { getList, remove, getCorpType } from "@/api/tirePartsMall/basicData/commodityInformation";
  103. import { getToken } from "@/util/auth";
  104. // import goodsType from '@/components/goodsType/index'
  105. import corpType from './components/index'
  106. export default {
  107. name: "index",
  108. data() {
  109. return {
  110. goodsTypeVisible: false,
  111. src: '',
  112. key:0,
  113. show: true,
  114. loading: false,
  115. search: {},
  116. detailData: {},
  117. dataList: [],
  118. selectionList: [],
  119. page: {
  120. pageSize: 20,
  121. currentPage: 1,
  122. total: 0,
  123. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  124. },
  125. option: {},
  126. treeData: [],
  127. form2: {},
  128. option2: {
  129. menuBtn: false,
  130. labelWidth: 80,
  131. column: [
  132. {
  133. label: "分类名称",
  134. prop: "cname",
  135. rules: [
  136. {
  137. required: true,
  138. message: "",
  139. trigger: "blur"
  140. }
  141. ],
  142. span: 24,
  143. },
  144. {
  145. label: "上级类型",
  146. prop: "parentId",
  147. dicData: [],
  148. type: "tree",
  149. props: {
  150. label: "title",
  151. value: "id"
  152. },
  153. span: 24,
  154. }
  155. ]
  156. },
  157. treeOption: {
  158. addBtn: false,
  159. menu: false,
  160. size: "small",
  161. props: {
  162. labelText: "标题",
  163. label: "title",
  164. value: "value",
  165. }
  166. },
  167. excelBox: false,
  168. excelForm: {},
  169. excelOption: {
  170. submitBtn: false,
  171. emptyBtn: false,
  172. column: [
  173. {
  174. label: "模板下载",
  175. prop: "excelTemplate",
  176. formslot: true,
  177. span: 24
  178. },
  179. {
  180. label: "模板上传",
  181. prop: "excelFile",
  182. type: "upload",
  183. drag: true,
  184. loadText: "模板上传中,请稍等",
  185. span: 24,
  186. propsHttp: {
  187. res: "data"
  188. },
  189. tip: "请上传 .xls,.xlsx 标准格式文件",
  190. action: "/api/blade-sales-part/goodsDesc/import-desc"
  191. }
  192. ]
  193. }
  194. };
  195. },
  196. components: {
  197. detailsPage,
  198. corpType,
  199. // goodsType
  200. },
  201. async created() {
  202. this.option = await this.getColumnData(this.getColumnName(217), option);
  203. this.key++
  204. this.getAllWorkDicts()
  205. },
  206. activated() {
  207. this.$refs.crud.refreshTable();
  208. },
  209. methods: {
  210. getAllWorkDicts() {
  211. // getCorpsAll().then(res => {
  212. // this.findObject(this.option.column, "cname").dicData = res.data.data;
  213. // this.findObject(this.option.column, "ids").dicData = res.data.data;
  214. // })
  215. // "/api/blade-system/dict-biz/dictionary?code=label",
  216. // this.getWorkDicts("label").then(res => {
  217. // this.findObject(this.option.column, "label").dicData = res.data.data;
  218. // });
  219. // this.getWorkDicts("unit").then(res => {
  220. // this.findObject(this.option.column, "unit").dicData = res.data.data;
  221. // });
  222. // this.getWorkDicts("goods_status").then(res => {
  223. // this.findObject(this.option.column, "status").dicData = res.data.data;
  224. // });
  225. // getAllgoods().then(res => {
  226. // this.findObject(this.option.column, "cname").dicData = res.data.data
  227. // });
  228. getCorpType({ corpType: 'SP' }).then(res => {
  229. this.treeData = res.data.data;
  230. // this.findObject(this.option2.column, "parentId").dicData = res.data.data;
  231. });
  232. this.$refs.crud.init();
  233. },
  234. searchCriteriaSwitch(type) {
  235. this.$refs.crud.getTableHeight();
  236. },
  237. derivation() {
  238. window.open(
  239. `/api/blade-sales-part/goodsDesc/export-template?${this.website.tokenHeader
  240. }=${getToken()}`
  241. );
  242. },
  243. //导出
  244. outExport() {
  245. let config = { params: { ...this.search } }
  246. if (config.params) {
  247. for (const propName of Object.keys(config.params)) {
  248. const value = config.params[propName];
  249. if (value !== null && typeof (value) !== "undefined") {
  250. if (value instanceof Array) {
  251. for (const key of Object.keys(value)) {
  252. let params = propName + '[' + key + ']';
  253. config.params[params] = value[key]
  254. }
  255. delete config.params[propName]
  256. }
  257. }
  258. }
  259. }
  260. const routeData = this.$router.resolve({
  261. path: '/api/blade-sales-part/goodsDesc/exportGoodsList', //跳转目标窗口的地址
  262. query: {
  263. ...config.params, //括号内是要传递给新窗口的参数
  264. identification: this.url
  265. }
  266. })
  267. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  268. },
  269. uploadAfter(res, done, loading, column) {
  270. this.excelBox = false;
  271. this.refreshChange();
  272. done();
  273. },
  274. cellStyle() {
  275. return "padding:0;height:40px;";
  276. },
  277. //点击搜索按钮触发
  278. searchChange(params, done) {
  279. this.page.currentPage = 1;
  280. this.onLoad(this.page, params);
  281. done();
  282. },
  283. refreshChange() {
  284. this.onLoad(this.page, this.search);
  285. },
  286. newAdd() {
  287. this.detailData = {
  288. goodsTypeId: this.search.goodsTypeId
  289. };
  290. this.show = false;
  291. },
  292. saveGoodstype() {
  293. // this.$refs["goodsType"].validate((valid, done) => {
  294. // done();
  295. // if (valid) {
  296. // goodsTypesubmit({ ...this.form2, status: 0 }).then(res => {
  297. // this.getAllWorkDicts()
  298. // })
  299. // this.goodsTypeVisible = false
  300. // } else {
  301. // return false;
  302. // }
  303. // });
  304. this.getAllWorkDicts()
  305. this.goodsTypeVisible = false
  306. },
  307. goodsTypeClosed() {
  308. // this.reload = Math.random();
  309. // this.form2 = this.$options.data().form2
  310. },
  311. nodeClick(data) {
  312. this.search.goodsTypeId = data.value
  313. this.page.currentPage = 1;
  314. this.onLoad(this.page, this.search);
  315. },
  316. onLoad(page, params = {}) {
  317. let data = this.deepClone(Object.assign(params, this.search));
  318. this.loading = true;
  319. getList({
  320. ...data,
  321. current: page.currentPage,
  322. size: page.pageSize
  323. }).then(res => {
  324. console.log(123214);
  325. this.dataList = res.data.data.records ? res.data.data.records : [];
  326. this.page.total = res.data.data.total;
  327. this.$nextTick(() => {
  328. this.$refs.crud.doLayout();
  329. this.$refs.crud.dicInit();
  330. });
  331. }).finally(() => {
  332. this.loading = false;
  333. });
  334. },
  335. editOpen(row, status) {
  336. this.detailData = {
  337. id: row.id,
  338. status: status
  339. };
  340. this.show = false;
  341. },
  342. currentChange(val) {
  343. this.page.currentPage = val;
  344. },
  345. sizeChange(val) {
  346. this.page.currentPage = 1;
  347. this.page.pageSize = val;
  348. },
  349. rowDel(row, index, done) {
  350. this.$confirm("确定删除数据?", {
  351. confirmButtonText: "确定",
  352. cancelButtonText: "取消",
  353. type: "warning"
  354. }).then(() => {
  355. remove({ id: row.id }).then(res => {
  356. if (res.data.code == 200) {
  357. this.$message({
  358. type: "success",
  359. message: "删除成功!"
  360. });
  361. this.onLoad(this.page, this.search);
  362. }
  363. });
  364. });
  365. },
  366. async saveColumn() {
  367. const inSave = await this.saveColumnData(
  368. this.getColumnName(217),
  369. this.option
  370. );
  371. if (inSave) {
  372. this.$nextTick(() => {
  373. this.$refs.crud.doLayout();
  374. this.$refs.crud.dicInit();
  375. });
  376. this.$message.success("保存成功");
  377. //关闭窗口
  378. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  379. }
  380. },
  381. async resetColumn() {
  382. this.option = option;
  383. const inSave = await this.delColumnData(this.getColumnName(217), option);
  384. if (inSave) {
  385. this.$nextTick(() => {
  386. this.$refs.crud.doLayout();
  387. this.$refs.crud.dicInit();
  388. });
  389. this.getAllWorkDicts()
  390. this.$message.success("重置成功");
  391. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  392. }
  393. },
  394. //返回列表
  395. goBack() {
  396. this.detailData = this.$options.data().detailData;
  397. this.show = true;
  398. this.onLoad(this.page, this.search);
  399. },
  400. }
  401. }
  402. </script>
  403. <style lang="scss" scoped>
  404. .page-crad ::v-deep .basic-container__card {
  405. height: 94.2vh;
  406. }
  407. ::v-deep .el-input-group__append {
  408. padding: 0 0px !important;
  409. }
  410. .stat-td {
  411. text-align: center;
  412. position: relative;
  413. }
  414. .stat-img {
  415. width: 95%;
  416. height: 100px;
  417. }
  418. .stat-tip {
  419. position: absolute;
  420. left: 15px;
  421. top: 5px;
  422. .money {
  423. color: #fff;
  424. font-size: 28px;
  425. text-align: left;
  426. font-weight: 600;
  427. }
  428. .title {
  429. color: #fff;
  430. font-size: 14px;
  431. text-align: left;
  432. margin-top: 5px;
  433. margin-bottom: 0px;
  434. }
  435. }
  436. </style>