index.vue 15 KB

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