index.vue 14 KB

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