index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="24">
  4. <el-col :span="4">
  5. <el-card style="height: 100%; min-height: 100vh;">
  6. <a href="#/basicData/productClass">
  7. <span style="font-size: 23px;">产品分类</span>
  8. <img style="margin-left: 40px;width: 12%; height: 12%;" src="../../../assets/images/bj1.png">
  9. </a>
  10. <div style="marginTop:20px;margin-left: 10px;">
  11. <el-tree
  12. :data="productNameList"
  13. v-model="table.getdataListParm.parammaps.categoryId"
  14. :props="defaultProps"
  15. @node-click="handleNodeClick"
  16. style="font-size: 26px;"
  17. :disabled="false"
  18. ></el-tree>
  19. </div>
  20. </el-card>
  21. </el-col>
  22. <el-col :span="20">
  23. <div class="operation">
  24. <el-button v-if="isRoleEdit" class="success" style="float: left;margin-right:10px;" @click="form_add">添加</el-button>
  25. <!-- <el-button v-if="isRoleEdit" class="import" style="float: right;" @click="form_inport">导入</el-button>
  26. <el-dropdown style="float: right;margin-right: 10px;">
  27. <el-button class="export">导出</el-button>
  28. <el-dropdown-menu slot="dropdown">
  29. <el-dropdown-item @click.native="form_export(1)">导出模板</el-dropdown-item>
  30. <el-dropdown-item @click.native="form_export(2)">导出数据</el-dropdown-item>
  31. </el-dropdown-menu>
  32. </el-dropdown> -->
  33. </div>
  34. <div class="search">
  35. <!-- <el-select v-model="table.getdataListParm.parammaps.categoryId" placeholder="产品类别" class="filter-item" style="width: 120px;" clearable>
  36. <el-option v-for="(item,index) in productNameList" :key="index" :label="item.name" :value="item.id" />
  37. </el-select> -->
  38. <tree-select
  39. v-model="table.getdataListParm.parammaps.categoryId"
  40. class="typeSelect"
  41. :height="300"
  42. :width="250"
  43. clearable
  44. :data="productNameList"
  45. :placeholder="placeholder"
  46. style="display: inline-block"
  47. :default-props="defaultProps"
  48. :node-key="nodeKey"
  49. :checked-keys="defaultCheckedKeysSelect"
  50. @popoverHide="popoverHideSelect"
  51. :disabled="false"
  52. />
  53. <el-input v-model="table.getdataListParm.parammaps.pname" placeholder="产品名称" style="width: 180px;" class="filter-item" clearable />
  54. <el-input v-model="table.getdataListParm.parammaps.pcode" placeholder="产品编码" style="width: 180px;" class="filter-item" clearable />
  55. <el-input v-model="table.getdataListParm.parammaps.model" placeholder="产品型号" style="width: 180px;" class="filter-item" clearable />
  56. <el-input v-model="table.getdataListParm.parammaps.Specifications" placeholder="产品规格" style="width: 180px;" class="filter-item" clearable />
  57. <el-button class="successBorder" @click="form_search">查询</el-button>
  58. <el-button class="successBorder" @click="form_clear">重置</el-button>
  59. </div>
  60. <div class="table">
  61. <el-table :key="table.tableKey" v-loading="table.listLoading" element-loading-text="给我一点时间" :data="table.list" border fit highlight-current-row style="width: 100%;" :row-style="rowStyle" :cell-style="cellStyle" class="elTable table-fixed">
  62. <!-- <el-table-column type="selection" align="center" width="50" /> -->
  63. <el-table-column label="序号" align="center" type="index" width="50px">
  64. <template slot-scope="scope">
  65. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="产品类别" min-width="150px" align="center">
  69. <template slot-scope="scope">
  70. <span>{{ scope.row.cname }}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="产品编码" min-width="150px" align="center">
  74. <template slot-scope="scope">
  75. <span>{{ scope.row.pcode }}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="产品名称" min-width="150px" align="center">
  79. <template slot-scope="scope">
  80. <span>{{ scope.row.pname }}</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="产品型号" min-width="150px" align="center">
  84. <template slot-scope="scope">
  85. <span>{{ scope.row.model }}</span>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="产品规格" min-width="150px" align="center">
  89. <template slot-scope="scope">
  90. <span>{{ scope.row.Specifications }}</span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="产品图片" min-width="150px" align="center">
  94. <template slot-scope="scope">
  95. <el-popover placement="right" title="" trigger="hover">
  96. <!-- 判断 imagePath 是否存在 -->
  97. <template v-if="scope.row.imagePath">
  98. <img
  99. slot="reference"
  100. :src="scope.row.imagePath"
  101. style="height: 100px; width: 100px"
  102. />
  103. <!-- 悬停时显示的内容 -->
  104. <img
  105. :src="scope.row.imagePath"
  106. style="height: 200px; width: 200px"
  107. />
  108. </template>
  109. <!-- 如果 imagePath 不存在,不显示任何内容 -->
  110. <template v-else></template>
  111. </el-popover>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="备注" min-width="150px" align="center">
  115. <template slot-scope="scope">
  116. <span>{{ scope.row.remark }}</span>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="顺序" width="100px" header-align="center" align="center">
  120. <template slot-scope="scope">
  121. <span>{{ scope.row.sort }}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="启用" min-width="80px" header-align="center" align="center">
  125. <template slot-scope="scope">
  126. <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="change_enable(scope.$index, scope.row)" />
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  130. <template slot-scope="{row}">
  131. <!-- <el-button v-if="isRoleEdit" class="miniSuccess" @click="form_edit(row)">编辑</el-button>
  132. <el-button v-if="isRoleEdit" class="miniDanger" @click="form_delete(row)">删除</el-button> -->
  133. <el-button class="miniSuccess" @click="form_edit(row)">编辑</el-button>
  134. <el-button class="miniDanger" @click="form_delete(row)">删除</el-button>
  135. </template>
  136. </el-table-column>
  137. </el-table>
  138. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="get_table_data" />
  139. </div>
  140. <!-- 新增/编辑 -->
  141. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="40%">
  142. <div class="app-add">
  143. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="150px" style="width: 80%;margin:0 auto 50px">
  144. <el-form-item label="产品类别:" style="width: 400px;" class="filter-item" prop="categoryId">
  145. <tree-select
  146. class="typeSelect"
  147. :height="300"
  148. :width="250"
  149. size="small"
  150. clearable
  151. :data="productNameList"
  152. :placeholder="placeholder"
  153. style="display:inline-block;"
  154. :default-props="defaultProps"
  155. :node-key="nodeKey"
  156. :checked-keys="defaultCheckedKeys"
  157. @popoverHide="popoverHide"
  158. :disabled="disabled"
  159. />
  160. </el-form-item>
  161. <el-form-item label="产品编码:" prop="pcode">
  162. <el-input ref="pname" v-model="create.temp.pcode" class="filter-item" style="width: 100%;" />
  163. </el-form-item>
  164. <el-form-item label="产品名称:" prop="pname">
  165. <el-input ref="pname" v-model="create.temp.pname" class="filter-item" style="width: 100%;" />
  166. </el-form-item>
  167. <el-form-item label="产品型号:" prop="model">
  168. <el-input ref="model" v-model="create.temp.model" class="filter-item" style="width: 100%;" />
  169. </el-form-item>
  170. <el-form-item label="产品规格:" prop="Specifications">
  171. <el-input ref="Specifications" v-model="create.temp.Specifications" class="filter-item" style="width: 100%;" />
  172. </el-form-item>
  173. <el-form-item label="备注:" prop="remark">
  174. <el-input ref="remark" class="filter-item" v-model="create.temp.remark" />
  175. </el-form-item>
  176. <el-form-item label="顺序:" prop="sort">
  177. <el-input ref="sort" class="filter-item" v-model="create.temp.sort" />
  178. </el-form-item>
  179. <el-form-item label="启用:" prop="enable">
  180. <el-switch ref="enable" class="filter-item" v-model="create.temp.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  181. </el-form-item>
  182. <el-form-item label="产品图片:">
  183. <el-upload id="uploadPic"
  184. :action="uploadImageUrl"
  185. :limit='1'
  186. :file-list="fileList"
  187. list-type="picture-card"
  188. :on-preview="handlePictureCardPreview"
  189. :on-change="(file, fileList) => handlePicChange(file, fileList)"
  190. :on-success="(response, file, fileList) => handlePicSuccess(response, file, fileList)"
  191. :headers="headers"
  192. :disabled="isView"
  193. :on-remove="(file, fileList) => handlePicRemove(file, fileList)"
  194. >
  195. <i slot="default" class="el-icon-plus"></i>
  196. </el-upload>
  197. <el-dialog :visible.sync="dialogVisible">
  198. <img width="100%" :src="dialogImageUrl" alt="">
  199. </el-dialog>
  200. </el-form-item>
  201. </el-form>
  202. <div slot="footer" class="dialog-footer">
  203. <el-button class="cancelClose" @click="create.dialogFormVisible = false;defaultCheckedKeys = [];this.dialogImageUrl = '';get_table_data()">关闭</el-button>
  204. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="success" @click="create.dialogStatus==='create'?add_dialog_save():form_edit_save();this.dialogImageUrl = '';">确认</el-button>
  205. </div>
  206. </div>
  207. </el-dialog>
  208. </el-col>
  209. </el-row>
  210. </div>
  211. </template>
  212. <script>
  213. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons, calculativeWidth,transData } from '@/api/common'
  214. import { isIntegerZero } from '@/utils/validate'
  215. import Cookies from 'js-cookie'
  216. import TreeSelect from '@/components/TreeSelect';
  217. import { parseTime } from '@/utils/index.js'
  218. import Pagination from '@/components/Pagination'
  219. import { MessageBox } from 'element-ui'
  220. import { getToken } from '@/utils/auth'
  221. export default {
  222. name: 'ProductList',
  223. components: { Pagination,TreeSelect },
  224. data() {
  225. return {
  226. handlePictureCardPreview(file) {
  227. this.dialogImageUrl = file.url;
  228. this.dialogVisible = true;
  229. },
  230. dialogImageUrl: '',
  231. dialogVisible: false,
  232. uploadImageUrl: process.env.VUE_APP_BASE_API + 'authdata/uploaderimage',
  233. //图片请求头
  234. headers: { optname: 'insertcustompic', id: 1,token: getToken()},
  235. isRoleEdit: [],
  236. productNameList: [], // 产品类别下拉框
  237. placeholder: '请选择上级分类',
  238. defaultProps: {
  239. children: 'children',
  240. label: 'name', // 根据实际字段名调整
  241. },
  242. disabled: false, // 是否禁用
  243. nodeKey: 'id', // 节点的唯一标识字段
  244. defaultCheckedKeys: [],
  245. defaultCheckedKeysSelect :[],
  246. fileList: [],
  247. //表格请求参数~
  248. table: {
  249. getdataListParm: {
  250. name: 'getProducts',
  251. page: 1,
  252. offset: 1,
  253. pagecount: parseInt(Cookies.get('pagecount')),
  254. returntype: 'Map',
  255. parammaps: {
  256. categoryId: '',
  257. pname: '',
  258. model: '',
  259. Specifications: '',
  260. pcode:'',
  261. }
  262. },
  263. tableKey: 0,
  264. list: [],
  265. total: 0,
  266. listLoading: true,
  267. temp: {}
  268. },
  269. // 新增/编辑
  270. create: {
  271. dialogFormVisible: false,
  272. dialogStatus: '',
  273. temp: {
  274. categoryId: '',
  275. pname: '',
  276. model: '',
  277. Specifications: '',
  278. remark: '',
  279. sort: '',
  280. enable: 1,
  281. pcode:'',
  282. pImage:'0',
  283. },
  284. rules: {
  285. pname: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  286. model: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  287. // Specifications: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  288. // sort: [{ validator: isIntegerZero, trigger: 'blur' }],
  289. pcode: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  290. },
  291. },
  292. textMap: {
  293. create: '添加',
  294. update: '编辑'
  295. },
  296. requestParam: {},
  297. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  298. cellStyle: { padding: 0 + 'px' }
  299. }
  300. },
  301. computed: {
  302. // 设置请求头
  303. headers() {
  304. return {
  305. // 设置token
  306. token: getToken()
  307. }
  308. }
  309. },
  310. created() {
  311. this.get_table_data()
  312. this.get_select_list()
  313. // this.get_auto_buttons()
  314. },
  315. methods: {
  316. handlePicChange(file, fileList) {
  317. },
  318. handlePicRemove(file, fileList) {
  319. console.log(file, fileList);
  320. console.log(fileList.length);
  321. if (fileList.length == 1) {
  322. document.getElementById('uploadPic').lastChild.style.display = "none"
  323. } else {
  324. document.getElementById('uploadPic').lastChild.style.display = "inline-block"
  325. this.$set(this.create.temp, 'pImage', '0');
  326. }
  327. },
  328. handlePicSuccess(response, file, fileList) {
  329. if (fileList.length == 1) {
  330. document.getElementById('uploadPic').lastChild.style.display = "none"
  331. } else {
  332. document.getElementById('uploadPic').lastChild.style.display = "inline-block"
  333. }
  334. this.$set(this.create.temp, 'pImage', response.execresult.LastInsertId);
  335. },
  336. andlePictureCardPreview(file) {
  337. this.dialogImageUrl = file.url;
  338. this.dialogVisible = true;
  339. },
  340. popoverHideSelect(checkedIds, checkedData) {
  341. if (checkedIds !== null) {
  342. this.table.getdataListParm.parammaps.categoryId = checkedData.id;
  343. } else {
  344. this.table.getdataListParm.parammaps.categoryId ='';
  345. }
  346. },
  347. handleNodeClick(data, node) {
  348. this.table.getdataListParm.parammaps.categoryId = data.id;
  349. this.get_table_data_left();
  350. },
  351. popoverHide(checkedIds, checkedData) {
  352. console.log(checkedIds, checkedData);
  353. if (checkedData == null) {
  354. this.$set(this.create.temp, 'pcode', '');
  355. this.create.temp.categoryId = '';
  356. }else{
  357. this.$set(this.create.temp, 'pcode', checkedData.code);
  358. this.create.temp.categoryId = checkedData.id;
  359. }
  360. },
  361. //获取按钮权限
  362. get_auto_buttons() {
  363. const Edit = 'DungScores'
  364. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  365. this.isRoleEdit = isRoleEdit
  366. },
  367. //获取所有下拉框的内容
  368. get_select_list() {
  369. GetDataByName({ name: 'getCategorySelect', offset: 0, pagecount: 0, parammaps: {} }, ).then(response => {
  370. this.productNameList = response.data.list
  371. this.productNameList= transData(response.data.list, 'id', 'pid', 'children');
  372. console.log("产品类别下拉框", response);
  373. })
  374. },
  375. //加载表格
  376. get_table_data() {
  377. this.table.listLoading = true
  378. console.log("this.table.getdataListParm======>", this.table.getdataListParm)
  379. GetDataByName(this.table.getdataListParm).then(response => {
  380. console.log('table数据======>', response.data.list)
  381. if (response.data.list !== null) {
  382. for (var i = 0; i < response.data.list.length; i++) {
  383. response.data.list[i].enable = parseInt(response.data.list[i].enable)
  384. if ( response.data.list[i].pImage !== '') {
  385. response.data.list[i].imagePath = process.env.VUE_APP_BASE_API + response.data.list[i].imagePath;
  386. } else {
  387. response.data.list[i].imagePath = ''
  388. }
  389. }
  390. this.table.list = response.data.list
  391. this.table.pageNum = response.data.pageNum
  392. this.table.pageSize = response.data.pageSize
  393. this.table.total = response.data.total
  394. console.log(this.table.list)
  395. } else {
  396. this.table.list = []
  397. }
  398. setTimeout(() => {
  399. this.table.listLoading = false
  400. }, 100)
  401. })
  402. },
  403. get_table_data_left() {
  404. this.table.listLoading = true
  405. console.log("this.table.getdataListParm======>", this.table.getdataListParm)
  406. GetDataByName(this.table.getdataListParm).then(response => {
  407. console.log('table数据======>', response.data.list)
  408. if (response.data.list !== null) {
  409. for (var i = 0; i < response.data.list.length; i++) {
  410. response.data.list[i].enable = parseInt(response.data.list[i].enable)
  411. if ( response.data.list[i].pImage !== '') {
  412. response.data.list[i].imagePath = process.env.VUE_APP_BASE_API + response.data.list[i].imagePath;
  413. } else {
  414. response.data.list[i].imagePath = ''
  415. }
  416. }
  417. this.table.list = response.data.list
  418. this.table.pageNum = response.data.pageNum
  419. this.table.pageSize = response.data.pageSize
  420. this.table.total = response.data.total
  421. } else {
  422. this.table.list = []
  423. }
  424. this.table.getdataListParm.parammaps.categoryId = '';
  425. setTimeout(() => {
  426. this.table.listLoading = false
  427. }, 100)
  428. })
  429. },
  430. form_search() {
  431. console.log('点击了查询')
  432. this.table.getdataListParm.offset = 1
  433. this.get_table_data()
  434. },
  435. form_clear() {
  436. console.log('点击了重置')
  437. this.table.getdataListParm.parammaps.categoryId = ''
  438. this.table.getdataListParm.parammaps.pname = ''
  439. this.table.getdataListParm.parammaps.model = ''
  440. this.table.getdataListParm.parammaps.Specifications = ''
  441. this.table.getdataListParm.offset = 1
  442. this.get_table_data()
  443. },
  444. // 添加
  445. form_reset() {
  446. this.create.temp = { categoryId: '', pname: '', model: '', Specifications: '', remark: '', sort: '', enable: 1 }
  447. },
  448. //监听 - 表格中产品类别
  449. change_bar(item) {
  450. this.create.temp.cname = this.productNameList.find(obj => obj.id === item).name
  451. },
  452. //添加
  453. form_add() {
  454. console.log('点击了新增')
  455. this.form_reset()
  456. // this.dialogImageUrl = row.imagePath;
  457. this.create.dialogStatus = 'create'
  458. this.create.dialogFormVisible = true
  459. document.getElementById('uploadPic').lastChild.style.display = "inline-block"
  460. this.fileList = [];
  461. // if (row.imagePath !== ''){
  462. // const fileList = [];
  463. // var urlObj = { "url": "", "response": { "execresult": { "LastInsertId": "" } } };
  464. // urlObj.url = row.imagePath;
  465. // urlObj.response.execresult.LastInsertId = row.pImage;
  466. // fileList.push(urlObj);
  467. // this.fileList = fileList;
  468. // }
  469. },
  470. //添加保存
  471. add_dialog_save() {
  472. console.log('点击了新增保存')
  473. this.$refs['temp'].validate(valid => {
  474. if (valid) {
  475. console.log(this.create.temp)
  476. //新增保存
  477. if (this.create.temp.pImage == null){
  478. this.create.temp.pImage = '0'
  479. }
  480. this.requestParam.name = 'insertProducts'
  481. this.requestParam.parammaps = this.create.temp
  482. this.requestParam = {
  483. data: [
  484. {
  485. name: "CheckProductPCode",
  486. type: "v",
  487. parammaps :{
  488. pcode :this.create.temp.pcode,
  489. id :''
  490. }
  491. },
  492. {
  493. name: "insertProducts",
  494. type: "e",
  495. parammaps: this.create.temp,
  496. },
  497. ]
  498. }
  499. ExecDataByConfig(this.requestParam).then(response => {
  500. // console.log('新增保存发送参数', this.requestParam)
  501. if (response.msg !== 'fail') {
  502. this.defaultCheckedKeys = [];
  503. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  504. this.create.dialogFormVisible = false
  505. this.get_table_data()
  506. } else {
  507. this.$notify({ title: '失败', message: response.data, type: 'error', duration: 2000 })
  508. }
  509. })
  510. }
  511. })
  512. },
  513. // 编辑
  514. form_edit(row) {
  515. console.log('点击了编辑', row)
  516. row.categoryId = String(row.categoryId)
  517. // this.dialogImageUrl = row.imagePath;
  518. this.create.temp = Object.assign({}, row)
  519. this.create.temp.id = row.id
  520. this.create.dialogStatus = 'update'
  521. this.create.dialogFormVisible = true
  522. // this.create.pcode = row.pcode;
  523. this.defaultCheckedKeys =[row.categoryId] ;
  524. // this.fileList = []
  525. console.log(row.imagePath);
  526. if (row.imagePath !== ''){
  527. const fileList = [];
  528. var urlObj = { "url": "", "response": { "execresult": { "LastInsertId": "" } } };
  529. urlObj.url = row.imagePath;
  530. urlObj.response.execresult.LastInsertId = row.pImage;
  531. fileList.push(urlObj);
  532. this.fileList = fileList;
  533. }else{
  534. this.fileList = [];
  535. this.dialogImageUrl = '';
  536. // this.isView = false;
  537. document.getElementById('uploadPic').lastChild.style.display = "inline-block"
  538. }
  539. console.log( 11111);
  540. console.log( this.dialogVisible);
  541. console.log( this.dialogImageUrl);
  542. console.log( 22222);
  543. },
  544. // 编辑保存
  545. form_edit_save() {
  546. this.$refs['temp'].validate(valid => {
  547. if (valid) {
  548. // this.requestParam.name = 'updateProducts'
  549. // this.requestParam.parammaps = this.create.temp
  550. if (this.create.temp.pImage === ""){
  551. this.create.temp.pImage = '0'
  552. }
  553. if (this.create.temp.sort === ""){
  554. this.create.temp.sort = '0'
  555. }
  556. this.requestParam = {
  557. data: [
  558. {
  559. name: "CheckProductPCode",
  560. type: "v",
  561. parammaps :{
  562. pcode :this.create.temp.pcode,
  563. id : this.create.temp.id
  564. }
  565. },
  566. {
  567. name: "updateProducts",
  568. type: "e",
  569. parammaps: this.create.temp,
  570. },
  571. ]
  572. }
  573. ExecDataByConfig(this.requestParam).then(response => {
  574. console.log('编辑保存发送参数', this.requestParam)
  575. if (response.msg !== 'fail') {
  576. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  577. this.create.dialogFormVisible = false
  578. this.defaultCheckedKeys = [];
  579. this.get_table_data()
  580. } else {
  581. this.$notify({ title: '失败', message: '保存失败', type: 'error', duration: 2000 })
  582. }
  583. })
  584. }
  585. })
  586. },
  587. // 表格中的启用
  588. change_enable(index, row) {
  589. this.requestParam.name = 'updateProducts'
  590. this.requestParam.parammaps = {
  591. id: row.id,
  592. categoryId: row.categoryId,
  593. pname: row.pname,
  594. model: row.model,
  595. Specifications: row.Specifications,
  596. cname: row.cname,
  597. remark: row.remark,
  598. sort: row.sort,
  599. enable: row.enable,
  600. pImage:row.pImage,
  601. }
  602. PostDataByName(this.requestParam).then(response => {
  603. console.log('表格中的启用发送参数', this.requestParam)
  604. if (response.msg !== 'fail') {
  605. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  606. this.create.dialogFormVisible = false
  607. this.get_table_data()
  608. } else {
  609. this.$notify({ title: '失败', message: '保存失败', type: 'error', duration: 2000 })
  610. }
  611. })
  612. },
  613. // 删除
  614. form_delete(row) {
  615. MessageBox.confirm('是否确认删除此信息?', {
  616. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  617. }).then(() => {
  618. this.requestParam.name = 'delProducts'
  619. this.requestParam.parammaps = {}
  620. this.requestParam.parammaps.id = row.id
  621. PostDataByName(this.requestParam).then(response => {
  622. if (response.msg === 'fail') {
  623. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  624. } else {
  625. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  626. this.get_table_data()
  627. }
  628. })
  629. }).catch(() => {
  630. this.$message({ type: 'info', message: '已取消删除' })
  631. })
  632. },
  633. // 导出
  634. form_export(item) {
  635. if (item == 1) {
  636. console.log('点击了导出模板')
  637. } else {
  638. console.log('点击了导出数据')
  639. }
  640. },
  641. // 导入
  642. form_inport() {
  643. console.log('点击了导入')
  644. }
  645. }
  646. }
  647. </script>
  648. <style lang="scss" scoped>
  649. .search {
  650. padding-top: 10px;
  651. clear: both;
  652. }
  653. .table {
  654. margin-top: 10px;
  655. }
  656. </style>
  657. <style lang="scss" scoped>
  658. .custom-tree {
  659. font-size: 26px; /* 设置字体大小 */
  660. }
  661. </style>