index.vue 14 KB

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