index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. <template>
  2. <zj-tab-page ref="tabPage" :defaultActives="[{ key: 'list', label: '列表页面', essential: true }]">
  3. <template slot-scope="{activeKey, data}">
  4. <template-page v-if="activeKey == 'list'" ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents"
  5. :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing" :operationColumnWidth="50"
  6. :operation="operation()" :exportList="exportList">
  7. </template-page>
  8. <div v-if="~['add', 'edit'].indexOf(activeKey)">
  9. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  10. <zj-form-module title="" label-width="170px" :showPackUp="false"
  11. :form-data="formData" :form-items="formItems" :disabled="formDialogType == 2">
  12. </zj-form-module>
  13. </zj-form-container>
  14. <div slot="footer" class="dialog-footer">
  15. <el-button size="mini" @click="data.removeTab()">取 消</el-button>
  16. <el-button v-if="formDialogType !== 2" size="mini" @click="formConfirm(data.removeTab)" type="primary">确 定</el-button>
  17. </div>
  18. </div>
  19. </template>
  20. </zj-tab-page>
  21. </template>
  22. <script>
  23. import TemplatePage from '@/components/template/template-page-1.vue'
  24. import import_mixin from '@/components/template/import_mixin.js'
  25. import ImageUpload from '@/components/file-upload'
  26. import { downloadFiles } from '@/utils/util'
  27. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  28. import { listPageV2, pageExport, getDetail, add, edit, updateStatus, listImport1, listImport2, getTypeList, getCategoryList } from "@/api/auxiliaryFittings/attachmentProfile";
  29. import { commonTemplateDownload } from '@/api/common.js'
  30. import operation_mixin from '@/components/template/operation_mixin.js'
  31. export default {
  32. components: { TemplatePage, ImageUpload },
  33. mixins: [import_mixin, operation_mixin],
  34. data() {
  35. return {
  36. // 表格属性
  37. tableAttributes: {
  38. // 启用勾选列
  39. selectColumn: true
  40. },
  41. // 表格事件
  42. tableEvents: {
  43. 'selection-change': this.selectionChange
  44. },
  45. // 勾选选中行
  46. recordSelected: [],
  47. /** 表单变量 */
  48. formDialogType: 0,
  49. formDialogTitles: ["新增", "编辑", "详情"],
  50. formDialog: false,
  51. formData: {
  52. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  53. goodsType: 'P',
  54. goodsStockUnit: '',
  55. goodsCode: '',
  56. goodsName: '',
  57. normType: 'M',
  58. status: 'ON',
  59. categoryList: [],
  60. brandList: [],
  61. marketPrice: '',
  62. normAmount: '',
  63. selfWebsitAmount: '',
  64. selfWorkerAmount: '',
  65. outWebsitAmount: '',
  66. outWorkerAmount: '',
  67. remark: ''
  68. },
  69. partsUnitList: [],
  70. brandList: [],
  71. categoryList: [],
  72. formType: 'add',
  73. formVisible: false,
  74. }
  75. },
  76. computed: {
  77. // 事件组合
  78. optionsEvensGroup() {
  79. return [
  80. [
  81. [
  82. this.optionsEvensAuth("add", {
  83. click: () => {
  84. this.openForm('add')
  85. }
  86. }),
  87. ],
  88. ],
  89. [
  90. [
  91. this.optionsEvensAuth("shelfInBulk", {
  92. click: () => {
  93. this.updateStatus('ON')
  94. }
  95. }),
  96. ],
  97. ],
  98. [
  99. [
  100. this.optionsEvensAuth("batchRemoval", {
  101. click: () => {
  102. this.updateStatus('OFF')
  103. }
  104. }),
  105. ],
  106. ],
  107. [
  108. [
  109. this.optionsEvensAuth("template", {
  110. click: this.handleDownload1
  111. }),
  112. ],
  113. [
  114. this.optionsEvensAuth("imp", ({ moduleName }) => {
  115. return {
  116. name: moduleName,
  117. render: () => {
  118. return this.importButton(listImport1, moduleName)
  119. }
  120. }
  121. }),
  122. ],
  123. ],
  124. [
  125. [
  126. this.optionsEvensAuth("importTemplate", {
  127. click: this.handleDownload2
  128. }),
  129. ],
  130. [
  131. this.optionsEvensAuth("Import", ({ moduleName }) => {
  132. return {
  133. name: moduleName,
  134. render: () => {
  135. return this.importButton(listImport2, moduleName)
  136. }
  137. }
  138. }),
  139. ],
  140. ]
  141. ]
  142. },
  143. // 更多参数
  144. moreParameters() {
  145. return []
  146. },
  147. //加法
  148. accAdd() {
  149. return function (arg1, arg2) {
  150. var r1, r2, m;
  151. try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
  152. try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
  153. m = Math.pow(10, Math.max(r1, r2))
  154. return (arg1 * m + arg2 * m) / m
  155. }
  156. },
  157. //减法
  158. Subtr() {
  159. return function (arg1, arg2) {
  160. var r1, r2, m, n;
  161. try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
  162. try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
  163. m = Math.pow(10, Math.max(r1, r2));
  164. n = (r1 >= r2) ? r1 : r2;
  165. return ((arg1 * m - arg2 * m) / m).toFixed(2);
  166. }
  167. },
  168. formItems() {
  169. return [{
  170. md: 6,
  171. isShow: true,
  172. name: 'el-input',
  173. attributes: { placeholder: '请输入', disabled: true },
  174. formItemAttributes: {
  175. label: '所属商户',
  176. prop: 'companyName',
  177. rules: [...required]
  178. },
  179. }, {
  180. md: 6,
  181. isShow: true,
  182. name: 'slot-component',
  183. attributes: {},
  184. formItemAttributes: {
  185. label: '状态',
  186. prop: 'status',
  187. rules: [...required]
  188. },
  189. render: (h, { props, onInput }) => {
  190. var { value } = props
  191. return (
  192. <el-radio-group v-model={this.formData.status}>
  193. <el-radio disabled={this.formDialogType == 2} label="ON">上架</el-radio>
  194. <el-radio disabled={this.formDialogType == 2} label="OFF">下架</el-radio>
  195. </el-radio-group>
  196. )
  197. }
  198. }, {
  199. md: 6,
  200. isShow: true,
  201. name: 'el-input',
  202. attributes: { placeholder: '请输入配件名称', },
  203. formItemAttributes: {
  204. label: '配件名称',
  205. prop: 'goodsName',
  206. rules: [...required]
  207. }
  208. }, {
  209. md: 6,
  210. isShow: true,
  211. name: 'el-select-add',
  212. labelKey: 'dictValue',
  213. valueKey: 'dictValue',
  214. options: this.partsUnitList,
  215. attributes: { placeholder: '请选择单位', filterable: true, clearable: true },
  216. formItemAttributes: {
  217. label: '单位',
  218. prop: 'goodsStockUnit',
  219. rules: [...required]
  220. },
  221. events: {
  222. change: (e) => {
  223. this.$refs.formRef.validateField(['goodsStockUnit'], (valid, invalidFields, errLabels) => { })
  224. }
  225. }
  226. }, {
  227. md: 6,
  228. isShow: true,
  229. name: 'el-input',
  230. attributes: { placeholder: '请输入配件代码' },
  231. formItemAttributes: {
  232. label: '配件代码',
  233. prop: 'goodsCode',
  234. rules: [...required]
  235. }
  236. }, {
  237. md: 6,
  238. isShow: true,
  239. name: 'slot-component',
  240. attributes: {},
  241. formItemAttributes: {
  242. label: '收费类型',
  243. prop: 'normType',
  244. rules: [...required]
  245. },
  246. render: (h, { props, onInput }) => {
  247. var { value } = props
  248. return (
  249. <el-radio-group v-model={this.formData.normType}>
  250. <el-radio disabled={this.formDialogType == 2} label="M">配件物料</el-radio>
  251. <el-radio disabled={this.formDialogType == 2} label="S">服务收费</el-radio>
  252. </el-radio-group>
  253. )
  254. }
  255. }, {
  256. md: 24,
  257. isShow: this.formData.normType == 'M' ? true : false,
  258. name: 'el-checkbox-add',
  259. labelKey: 'dictValue',
  260. valueKey: 'dictCode',
  261. attributes: {},
  262. options: this.brandList,
  263. formItemAttributes: {
  264. label: '适用品牌',
  265. prop: 'brandList',
  266. rules: [...required]
  267. },
  268. events: {
  269. change: (e) => {
  270. this.$refs.formRef.validateField(['brandList'], (valid, invalidFields, errLabels) => { })
  271. }
  272. }
  273. }, {
  274. md: 24,
  275. isShow: this.formData.normType == 'M' ? true : false,
  276. name: 'el-checkbox-add',
  277. labelKey: 'name',
  278. valueKey: 'categoryId',
  279. attributes: {},
  280. options: this.categoryList,
  281. formItemAttributes: {
  282. label: '适用产品大类',
  283. prop: 'categoryList',
  284. rules: [...required]
  285. },
  286. events: {
  287. change: (e) => {
  288. this.$refs.formRef.validateField(['categoryList'], (valid, invalidFields, errLabels) => { })
  289. }
  290. }
  291. }, {
  292. md: 6,
  293. isShow: this.formData.normType == 'M' ? true : false,
  294. name: 'slot-component',
  295. attributes: { placeholder: '请输入', type: 'number' },
  296. formItemAttributes: {
  297. label: '销售价格',
  298. prop: 'marketPrice',
  299. rules: [...required]
  300. },
  301. render: (h, { props, onInput }) => {
  302. var { value } = props
  303. return (
  304. <div style="position: relative;">
  305. <div style="display: flex;justify-content: space-around;align-items: center;position: relative;">
  306. <el-input v-model={this.formData.marketPrice} type="number" placeholder="请输入"></el-input><span style="margin-left: 10px;">元</span>
  307. </div>
  308. <div style="color: #EA8000">注:维护网点销售给师傅的价格</div>
  309. </div>
  310. )
  311. }
  312. }, {
  313. md: 6,
  314. isShow: this.formData.normType == 'M' ? true : false,
  315. name: 'slot-component',
  316. attributes: { placeholder: '请输入', type: 'number' },
  317. formItemAttributes: {
  318. label: '收费标准',
  319. prop: 'normAmount',
  320. rules: [...required]
  321. },
  322. render: (h, { props, onInput }) => {
  323. var { value } = props
  324. return (
  325. <div style="position: relative;">
  326. <div style="display: flex;justify-content: space-around;align-items: center;position: relative;">
  327. <el-input v-model={this.formData.normAmount} onChange={(e) => {
  328. this.formData.normAmount = Number(e).toFixed(2)
  329. if (this.formData.selfWorkerAmount > e) {
  330. this.formData.normAmount = ''
  331. return this.$message.warning('自有库存师傅分账金额必须小于收费标准!');
  332. } else if (this.formData.outWorkerAmount > e) {
  333. this.formData.outWorkerAmount = ''
  334. return this.$message.warning('外购配件师傅分账金额必须小于收费标准!');
  335. }
  336. this.formData.selfWebsitAmount = this.Subtr(e, this.formData.selfWorkerAmount)
  337. this.formData.outWebsitAmount = this.Subtr(e, this.formData.outWorkerAmount)
  338. this.$refs.formRef.validateField(['selfWebsitAmount'], (valid, invalidFields, errLabels) => { })
  339. this.$refs.formRef.validateField(['outWebsitAmount'], (valid, invalidFields, errLabels) => { })
  340. }} type="number" placeholder="请输入"></el-input><span style="margin-left: 10px;">元</span>
  341. </div>
  342. <div style="color: #EA8000">注:分账金额需扣除手续费0.6%</div>
  343. </div>
  344. )
  345. }
  346. }, {
  347. md: 6,
  348. isShow: this.formData.normType == 'M' ? true : false,
  349. name: 'slot-component',
  350. attributes: { placeholder: '请输入', type: 'number' },
  351. formItemAttributes: {
  352. label: '自有库存师傅分账金额',
  353. prop: 'selfWorkerAmount',
  354. rules: [...required]
  355. },
  356. render: (h, { props, onInput }) => {
  357. var { value } = props
  358. const that = this
  359. return (
  360. <div style="position: relative;">
  361. <div style="display: flex;justify-content: space-around;align-items: center;position: relative;">
  362. <el-input v-model={this.formData.selfWorkerAmount} onChange={(e) => {
  363. this.formData.selfWorkerAmount = Number(this.formData.selfWorkerAmount).toFixed(2)
  364. if (e && (Number(e) > Number(that.formData.normAmount))) {
  365. that.formData.selfWorkerAmount = ''
  366. return this.$message.warning('自有库存师傅分账金额必须小于收费标准!');
  367. }
  368. that.formData.selfWebsitAmount = this.Subtr(that.formData.normAmount, e)
  369. }} type="number" placeholder="请输入"></el-input><span style="margin-left: 10px;">元</span>
  370. </div>
  371. </div>
  372. )
  373. }
  374. }, {
  375. md: 6,
  376. isShow: this.formData.normType == 'M' ? false : true,
  377. name: 'slot-component',
  378. attributes: { placeholder: '请输入', type: 'number' },
  379. formItemAttributes: {
  380. label: '师傅分账比例',
  381. prop: 'selfWorkerAmount',
  382. rules: [...required]
  383. },
  384. render: (h, { props, onInput }) => {
  385. var { value } = props
  386. const that = this
  387. return (
  388. <div style="position: relative;">
  389. <div style="display: flex;justify-content: space-around;align-items: center;position: relative;">
  390. <el-input v-model={this.formData.selfWorkerAmount} onChange={(e) => {
  391. this.formData.selfWorkerAmount = Number(this.formData.selfWorkerAmount).toFixed(2)
  392. if (e && (Number(e) < 0)) {
  393. return this.$message.warning('师傅分账比例不能为0!');
  394. }
  395. if (e && (this.accAdd(Number(e), Number(that.formData.selfWebsitAmount)) > 100)) {
  396. this.formData.selfWorkerAmount = 0
  397. return this.$message.warning('商户与师傅分账比例和最大只能100%!');
  398. } else {
  399. that.formData.selfWebsitAmount = this.Subtr(100, e)
  400. }
  401. }} type="number" placeholder="请输入"></el-input><span style="margin-left: 10px;">%</span>
  402. </div>
  403. </div>
  404. )
  405. }
  406. }, {
  407. md: 6,
  408. isShow: this.formData.normType == 'M' ? true : false,
  409. name: 'slot-component',
  410. attributes: { placeholder: '请输入', type: 'number' },
  411. formItemAttributes: {
  412. label: '外购配件师傅分账金额',
  413. prop: 'outWorkerAmount',
  414. rules: [...required]
  415. },
  416. render: (h, { props, onInput }) => {
  417. var { value } = props
  418. const that = this
  419. return (
  420. <div style="position: relative;">
  421. <div style="display: flex;justify-content: space-around;align-items: center;position: relative;">
  422. <el-input v-model={this.formData.outWorkerAmount} onChange={(e) => {
  423. this.formData.outWorkerAmount = Number(this.formData.outWorkerAmount).toFixed(2)
  424. if (Number(e) > Number(that.formData.normAmount)) {
  425. this.formData.outWorkerAmount = ''
  426. return this.$message.warning('外购配件师傅分账金额必须小于收费标准!');
  427. }
  428. this.formData.outWebsitAmount = this.Subtr(this.formData.normAmount, e)
  429. }} type="number" placeholder="请输入"></el-input><span style="margin-left: 10px;">元</span>
  430. </div>
  431. </div>
  432. )
  433. }
  434. }, {
  435. md: 6,
  436. isShow: this.formData.normType == 'M' ? true : false,
  437. name: 'slot-component',
  438. attributes: { placeholder: '请输入', type: 'number' },
  439. formItemAttributes: {
  440. label: '自有库存商户分账金额',
  441. prop: 'selfWebsitAmount',
  442. rules: [...required]
  443. },
  444. render: (h, { props, onInput }) => {
  445. var { value } = props
  446. return (
  447. <div style="position: relative;">
  448. <div style="display: flex;justify-content: space-around;align-items: center;position: relative;">
  449. <el-input v-model={this.formData.selfWebsitAmount} disabled type="number" placeholder="请输入"></el-input><span style="margin-left: 10px;">元</span>
  450. </div>
  451. </div>
  452. )
  453. }
  454. }, {
  455. md: 6,
  456. isShow: this.formData.normType == 'M' ? false : true,
  457. name: 'slot-component',
  458. attributes: { placeholder: '请输入', type: 'number' },
  459. formItemAttributes: {
  460. label: '商户分账比例',
  461. prop: 'selfWebsitAmount',
  462. rules: [...required]
  463. },
  464. render: (h, { props, onInput }) => {
  465. var { value } = props
  466. const that = this
  467. return (
  468. <div style="position: relative;">
  469. <div style="display: flex;justify-content: space-around;align-items: center;position: relative;">
  470. <el-input v-model={this.formData.selfWebsitAmount} onChange={(e) => {
  471. this.formData.selfWebsitAmount = Number(this.formData.selfWebsitAmount).toFixed(2)
  472. if (e && (Number(e) < 0)) {
  473. return this.$message.warning('商户分账比例不能为0!');
  474. }
  475. if (e && (this.accAdd(Number(e), Number(that.formData.selfWorkerAmount)) > 100)) {
  476. this.formData.selfWebsitAmount = 0
  477. return this.$message.warning('商户与师傅分账比例和最大只能100%!');
  478. } else {
  479. that.formData.selfWorkerAmount = this.Subtr(100, e)
  480. }
  481. }} type="number" placeholder="请输入"></el-input><span style="margin-left: 10px;">%</span>
  482. </div>
  483. </div>
  484. )
  485. }
  486. }, {
  487. md: 6,
  488. isShow: this.formData.normType == 'M' ? true : false,
  489. name: 'slot-component',
  490. attributes: { placeholder: '请输入', type: 'number' },
  491. formItemAttributes: {
  492. label: '外购配件商户分账金额',
  493. prop: 'outWebsitAmount',
  494. rules: [...required]
  495. },
  496. render: (h, { props, onInput }) => {
  497. var { value } = props
  498. return (
  499. <div style="position: relative;">
  500. <div style="display: flex;justify-content: space-around;align-items: center;position: relative;">
  501. <el-input v-model={this.formData.outWebsitAmount} disabled type="number" placeholder="请输入"></el-input><span style="margin-left: 10px;">元</span>
  502. </div>
  503. </div>
  504. )
  505. }
  506. }, {
  507. md: 24,
  508. isShow: true,
  509. name: 'el-input',
  510. attributes: { placeholder: '请输入备注内容', type: "textarea", rows: 5 },
  511. formItemAttributes: {
  512. label: '备注',
  513. prop: 'remark',
  514. rules: []
  515. }
  516. }]
  517. }
  518. },
  519. methods: {
  520. // 列表请求函数
  521. getList(p, cb) {
  522. try {
  523. var pam = JSON.parse(JSON.stringify(p))
  524. if (this.examineStatus) {
  525. pam.params.push({ "param": "b.examine_status", "compare": "=", "value": this.examineStatus })
  526. }
  527. cb && cb(pam)
  528. return listPageV2(pam)
  529. } catch (error) {
  530. console.log(error)
  531. }
  532. },
  533. getTypeList(value, type) {
  534. getTypeList({ "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.dict_type", "compare": "=", "value": `${value}` }, { "param": "a.status", "compare": "=", "value": "ON" }] }).then(res => {
  535. this[type] = res.data.records
  536. })
  537. },
  538. getCategoryList() {
  539. getCategoryList({ "type": 2 }).then(res => {
  540. this.categoryList = res.data
  541. })
  542. },
  543. // 列表导出函数
  544. exportList: pageExport,
  545. // 表格列解析渲染数据更改
  546. columnParsing(item, defaultData) {
  547. if (item.jname === 'idCardImg') {
  548. defaultData.render = (h, { row, index, column }) => {
  549. return (
  550. <div style="padding:0 6px;cursor: pointer;">
  551. {row.idCardImg ? row.idCardImg.split(",").map(url => <el-image src={url} preview-src-list={[url]} fit="fit" style="width:80px;height:80px;" />) : null}
  552. </div>
  553. )
  554. }
  555. }
  556. if (item.jname === 'selfWorkerAmount') {
  557. defaultData.render = (h, { row, index, column }) => {
  558. return (
  559. <div>{row.normType == 'M' ? row.selfWorkerAmount : (row.selfWorkerAmount + '%')}</div>
  560. )
  561. }
  562. }
  563. if (item.jname === 'selfWebsitAmount') {
  564. defaultData.render = (h, { row, index, column }) => {
  565. return (
  566. <div>{row.normType == 'M' ? row.selfWebsitAmount : (row.selfWebsitAmount + '%')}</div>
  567. )
  568. }
  569. }
  570. return defaultData
  571. },
  572. // 监听勾选变化
  573. selectionChange(data) {
  574. this.recordSelected = data
  575. },
  576. operation() {
  577. return this.operationBtn({
  578. edit: {
  579. click: ({ row, index, column }) => {
  580. this.openForm('edit',row.goodsId)
  581. }
  582. },
  583. })
  584. },
  585. // 打开 新增编辑 网点表单
  586. openForm(type, id) {
  587. this.$refs.tabPage.addTab({
  588. // 对应显示的模块
  589. activeKey: type,
  590. // 唯一标识
  591. key: type,
  592. // 页签名称
  593. label: ({ edit: "编辑", add: "新增" })[type],
  594. // 打开时事件
  595. triggerEvent: () => {
  596. this.formCancel()
  597. this.$nextTick(()=>{
  598. this.formType = type
  599. this.formVisible = true
  600. this.getTypeList('PARTS_UNIT', 'partsUnitList')
  601. this.getTypeList('BRAND', 'brandList')
  602. this.getCategoryList()
  603. if (type == 'add') {
  604. this.formDialogType = 0
  605. } else if(type == 'edit'){
  606. this.formDialogType = 1
  607. getDetail({ id }).then(res => {
  608. Object.assign(this.formData, res.data, {
  609. brandList: res.data.brandList ? res.data.brandList : [],
  610. categoryList: res.data.categoryList ? res.data.categoryList : [],
  611. })
  612. })
  613. }
  614. })
  615. },
  616. // 关闭时事件
  617. closeEvent: () => {
  618. }
  619. })
  620. },
  621. formCancel() {
  622. this.formVisible = false
  623. this.$refs?.formRef?.resetFields()
  624. this.$data.formRef = this.$options.data().formRef
  625. },
  626. updateStatus(stateEnum) {
  627. if (this.recordSelected.length == 0) {
  628. return this.$message.warning('请至少勾选一条数据!');
  629. }
  630. console.log(this.recordSelected)
  631. this.$confirm(`请确认是否${stateEnum == 'OFF' ? '下架' : '上架'}该配件, 是否继续?`, '提示', {
  632. confirmButtonText: '确定',
  633. cancelButtonText: '取消',
  634. type: 'warning'
  635. }).then(() => {
  636. updateStatus({
  637. stateEnum,
  638. ids: this.recordSelected.map(item => { return item.goodsId }).join(',')
  639. }).then(res => {
  640. if (res.code == 200) {
  641. this.$message({ type: 'success', message: `${stateEnum == 'ON' ? '上架' : '下架'}成功!` })
  642. this.$refs.pageRef.refreshList()
  643. } else {
  644. this.$message.error(res.msg);
  645. }
  646. })
  647. });
  648. },
  649. formConfirm(cancel) {
  650. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  651. if (valid) {
  652. ([add, edit][this.formDialogType])(this.formData).then(res => {
  653. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  654. cancel('list')
  655. this.$refs.pageRef.refreshList()
  656. })
  657. }
  658. })
  659. },
  660. // 下载导入模版
  661. handleDownload1() {
  662. commonTemplateDownload({ name: '配件模板(配件物料).xlsx' }, `${this.$route.meta.title}`).then(res => {
  663. this.$message({
  664. message: '下载成功',
  665. type: 'success'
  666. })
  667. }).catch(err => {
  668. this.$message.error('下载失败')
  669. })
  670. // downloadFiles('charging/standard/download');
  671. },
  672. handleDownload2() {
  673. commonTemplateDownload({ name: '配件模板(服务收费).xlsx' }, `${this.$route.meta.title}`).then(res => {
  674. this.$message({
  675. message: '下载成功',
  676. type: 'success'
  677. })
  678. }).catch(err => {
  679. this.$message.error('下载失败')
  680. })
  681. // downloadFiles('charging/standard/download');
  682. },
  683. }
  684. }
  685. </script>
  686. <style lang="scss" scoped>
  687. .tab {
  688. padding: 20px 20px 0 20px;
  689. }
  690. </style>