index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <template-page ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents" :operationColumnWidth="50"
  3. :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
  4. :operation="operation" :exportList="exportList">
  5. <el-dialog title="" width="1200px" custom-class="diy-dialog" append-to-body :modal="true" :visible.sync="formDialog"
  6. :show-close="true" :close-on-click-modal="false" :modal-append-to-body="false" :before-close="formCancel">
  7. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  8. <zj-form-module :title="formDialogTitles[formDialogType]" label-width="170px" :showPackUp="false"
  9. :form-data="formData" :form-items="formItems" :disabled="formDialogType==2">
  10. </zj-form-module>
  11. </zj-form-container>
  12. <div slot="footer" class="dialog-footer">
  13. <el-button size="mini" @click="formCancel">取 消</el-button>
  14. <el-button size="mini" type="primary" @click="formConfirm()">确定</el-button>
  15. </div>
  16. </el-dialog>
  17. </template-page>
  18. </template>
  19. <script>
  20. import TemplatePage from '@/components/template/template-page-1.vue'
  21. import import_mixin from '@/components/template/import_mixin.js'
  22. import ImageUpload from '@/components/file-upload'
  23. import { downloadFiles } from '@/utils/util'
  24. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  25. import { listPageV2,pageExport, getDetail, add, edit, updateStatus, listImport } from "@/api/auxiliaryFittings/attachmentProfile";
  26. export default {
  27. components: { TemplatePage, ImageUpload },
  28. mixins: [import_mixin],
  29. data() {
  30. return {
  31. // 事件组合
  32. optionsEvensGroup: [
  33. [
  34. [
  35. {
  36. name: '新建',
  37. click: this.addData
  38. }
  39. ]
  40. ],
  41. [
  42. [
  43. {
  44. name: '批量上架',
  45. click: ()=>{
  46. this.updateStatus('ON')
  47. }
  48. }
  49. ]
  50. ],
  51. [
  52. [
  53. {
  54. name: '批量下架',
  55. click: ()=>{
  56. this.updateStatus('OFF')
  57. }
  58. }
  59. ]
  60. ],[
  61. [
  62. {
  63. name: '下载导入模板',
  64. click: this.handleDownload
  65. }
  66. ],
  67. [
  68. {
  69. name: '导入模板',
  70. render: () => {
  71. return this.importButton(listImport, '导入模板')
  72. }
  73. }
  74. ],
  75. ],
  76. ],
  77. // 表格属性
  78. tableAttributes: {
  79. // 启用勾选列
  80. selectColumn: true
  81. },
  82. // 表格事件
  83. tableEvents: {
  84. 'selection-change': this.selectionChange
  85. },
  86. // 勾选选中行
  87. recordSelected: [],
  88. /** 表单变量 */
  89. formDialogType: 0,
  90. formDialogTitles: ["新增","编辑", "详情"],
  91. formDialog: false,
  92. formData: {
  93. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  94. brandList: [],
  95. categoryList: [],
  96. partsUnitName: ''
  97. }
  98. }
  99. },
  100. computed: {
  101. // 更多参数
  102. moreParameters() {
  103. return []
  104. },
  105. formItems() {
  106. return [{
  107. md: 12,
  108. isShow: true,
  109. name: 'el-input',
  110. attributes: { placeholder: '请输入', disabled: true },
  111. formItemAttributes: {
  112. label: '所属商户',
  113. prop: 'companyName',
  114. rules: [...required]
  115. },
  116. }, {
  117. md: 12,
  118. isShow: true,
  119. name: 'slot-component',
  120. attributes: { },
  121. formItemAttributes: {
  122. label: '状态',
  123. prop: 'stateEnum',
  124. rules: [...required]
  125. },
  126. render: (h, { props, onInput }) => {
  127. var { value } = props
  128. return (
  129. <el-radio-group v-model={this.formData.stateEnum}>
  130. <el-radio disabled={this.formDialogType==2} label="ON">上架</el-radio>
  131. <el-radio disabled={this.formDialogType==2} label="OFF">下架</el-radio>
  132. </el-radio-group>
  133. )
  134. }
  135. }, {
  136. md: 12,
  137. isShow: true,
  138. name: 'el-input',
  139. attributes: { placeholder: '请输入配件名称', },
  140. formItemAttributes: {
  141. label: '配件名称',
  142. prop: 'goodsName',
  143. rules: [...required]
  144. }
  145. }, {
  146. md: 12,
  147. isShow: true,
  148. name: 'el-select-add',
  149. options: [{
  150. label: `通用`,
  151. value: "通用"
  152. },
  153. {
  154. label: `格力`,
  155. value: "格力"
  156. },{
  157. label: `美的`,
  158. value: "美的"
  159. },
  160. {
  161. label: `海尔`,
  162. value: "海尔"
  163. },
  164. {
  165. label: `华凌`,
  166. value: "华凌"
  167. }],
  168. attributes: { placeholder: '请选择单位',filterable: true },
  169. formItemAttributes: {
  170. label: '单位',
  171. prop: 'partsUnitName',
  172. rules: [...required]
  173. },
  174. events: {
  175. change(e){
  176. console.log(e)
  177. }
  178. }
  179. }, {
  180. md: 12,
  181. isShow: true,
  182. name: 'el-input',
  183. attributes: { placeholder: '请输入配件代码' },
  184. formItemAttributes: {
  185. label: '配件代码',
  186. prop: 'goodsCode',
  187. rules: [...required]
  188. }
  189. }, {
  190. md: 12,
  191. isShow: true,
  192. name: 'slot-component',
  193. attributes: {},
  194. formItemAttributes: {
  195. label: '收费类型',
  196. prop: 'venderType',
  197. rules: [...required]
  198. },
  199. render: (h, { props, onInput }) => {
  200. var { value } = props
  201. return (
  202. <el-radio-group v-model={this.formData.venderType}>
  203. <el-radio disabled={this.formDialogType==2} label="P">配件物料</el-radio>
  204. <el-radio disabled={this.formDialogType==2} label="A">服务收费</el-radio>
  205. </el-radio-group>
  206. )
  207. }
  208. }, {
  209. md: 24,
  210. isShow: true,
  211. name: 'el-checkbox-add',
  212. attributes: {},
  213. options: [{
  214. label: `通用`,
  215. value: "通用"
  216. },
  217. {
  218. label: `格力`,
  219. value: "格力"
  220. },{
  221. label: `美的`,
  222. value: "美的"
  223. },
  224. {
  225. label: `海尔`,
  226. value: "海尔"
  227. },
  228. {
  229. label: `华凌`,
  230. value: "华凌"
  231. }],
  232. formItemAttributes: {
  233. label: '适用品牌',
  234. prop: 'brandList',
  235. rules: [...required]
  236. }
  237. }, {
  238. md: 24,
  239. isShow: true,
  240. name: 'el-checkbox-add',
  241. attributes: {},
  242. options: [{
  243. label: `通用`,
  244. value: "通用"
  245. },
  246. {
  247. label: `家用空调`,
  248. value: "家用空调"
  249. }],
  250. formItemAttributes: {
  251. label: '适用产品大类',
  252. prop: 'categoryList',
  253. rules: [...required]
  254. }
  255. }, {
  256. md: 12,
  257. isShow: true,
  258. name: 'el-input',
  259. attributes: { placeholder: '请输入', type: 'number' },
  260. formItemAttributes: {
  261. label: '销售价格',
  262. prop: 'www',
  263. rules: [...required]
  264. }
  265. }, {
  266. md: 12,
  267. isShow: true,
  268. name: 'el-input',
  269. attributes: { placeholder: '请输入', type: 'number' },
  270. formItemAttributes: {
  271. label: '收费标准',
  272. prop: 'email',
  273. rules: [...email]
  274. }
  275. }, {
  276. md: 12,
  277. isShow: true,
  278. name: 'el-input',
  279. attributes: { placeholder: '请输入', type: 'number' },
  280. formItemAttributes: {
  281. label: '自有库存师傅分账金额',
  282. prop: 'telNo',
  283. rules: [...required]
  284. }
  285. }, {
  286. md: 12,
  287. isShow: true,
  288. name: 'el-input',
  289. attributes: { placeholder: '请输入', type: 'number' },
  290. formItemAttributes: {
  291. label: '外购辅材师傅分账金额',
  292. prop: 'faxNo',
  293. rules: [...required]
  294. }
  295. }, {
  296. md: 12,
  297. isShow: true,
  298. name: 'el-input',
  299. attributes: { placeholder: '请输入', type: 'number' },
  300. formItemAttributes: {
  301. label: '自有库存网点分账金额',
  302. prop: 'telNo',
  303. rules: [...required]
  304. }
  305. }, {
  306. md: 12,
  307. isShow: true,
  308. name: 'el-input',
  309. attributes: { placeholder: '请输入', type: 'number' },
  310. formItemAttributes: {
  311. label: '外购辅材网点分账金额',
  312. prop: 'faxNo',
  313. rules: [...required]
  314. }
  315. }, {
  316. md: 24,
  317. isShow: true,
  318. name: 'el-input',
  319. attributes: { placeholder: '请输入备注内容',type: "textarea", rows: 5 },
  320. formItemAttributes: {
  321. label: '备注',
  322. prop: 'remark',
  323. rules: []
  324. }
  325. }]
  326. }
  327. },
  328. methods: {
  329. // 列表请求函数
  330. getList(p) {
  331. try {
  332. var pam = JSON.parse(JSON.stringify(p))
  333. if (this.examineStatus) {
  334. pam.params.push({ "param": "b.examine_status", "compare": "=", "value": this.examineStatus })
  335. }
  336. return listPageV2(pam)
  337. } catch (error) {
  338. console.log(error)
  339. }
  340. },
  341. // 列表导出函数
  342. exportList: pageExport,
  343. // 表格列解析渲染数据更改
  344. columnParsing(item, defaultData) {
  345. if (item.jname === 'idCardImg') {
  346.         defaultData.render = (h, { row, index, column }) => {
  347.           return (
  348.             <div style="padding:0 6px;cursor: pointer;">
  349.               {row.idCardImg ? row.idCardImg.split(",").map(url => <el-image src={url} preview-src-list={[url]} fit="fit" style="width:80px;height:80px;" />) : null}
  350.             </div>
  351.           )
  352.         }
  353.       }
  354. return defaultData
  355. },
  356. // 监听勾选变化
  357. selectionChange(data) {
  358. this.recordSelected = data
  359. },
  360. // 表格操作列
  361. operation(h, { row, index, column }) {
  362. return (
  363. <div class='operation-btns'>
  364. <el-button type="text" onClick={() => {
  365. getDetail({ id: row.venderId }).then(res => {
  366. Object.assign(this.formData, res.data,{
  367. imageUrl:res.data?.imageUrl? res.data?.imageUrl?.split(",").map(item=>({url:item})) : []
  368. })
  369. console.log(this.formData)
  370. this.formDialogType = 1
  371. this.openForm()
  372. })
  373. }}>编辑</el-button>
  374. </div>
  375. )
  376. },
  377. addData() {
  378. this.formDialogType = 0
  379. this.openForm()
  380. },
  381. openForm() {
  382. this.formDialog = true;
  383. },
  384. formCancel() {
  385. this.$refs.formRef.$refs.inlineForm.clearValidate()
  386. this.$data.formData = this.$options.data().formData
  387. this.formDialog = false
  388. },
  389. updateStatus(stateEnum){
  390. if(this.recordSelected.length == 0){
  391. return this.$message.warning('请至少勾选一条数据!');
  392. }
  393. console.log(this.recordSelected)
  394. this.$confirm(`请确认是否${stateEnum=='OFF'?'下架':'上架'}该配件, 是否继续?`, '提示', {
  395. confirmButtonText: '确定',
  396. cancelButtonText: '取消',
  397. type: 'warning'
  398. }).then(() => {
  399. memberInner({
  400. stateEnum,
  401. ids: this.recordSelected.map(item=>{return item.goodsId}).join(',')
  402. }).then(res => {
  403. if (res.code == 200) {
  404. this.$message({ type: 'success', message: `${stateEnum=='ON'?'下架':'上架'}成功!` })
  405. this.$refs.pageRef.refreshList()
  406. } else {
  407. this.$message.error(res.msg);
  408. }
  409. })
  410. });
  411. },
  412. formConfirm() {
  413. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  414. if (valid) {
  415. ([add, edit][this.formDialogType])({
  416. ...this.formData,
  417. imageUrl:this.formData.imageUrl.map(item=>item.url).join(",")
  418. }).then(res => {
  419. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  420. this.formCancel()
  421. this.$refs.pageRef.refreshList()
  422. })
  423. }
  424. })
  425. },
  426. // 下载导入模版
  427. handleDownload() {
  428. // downloadFiles('charging/standard/download');
  429. },
  430. }
  431. }
  432. </script>
  433. <style lang="scss" scoped>
  434. .tab{
  435. padding: 20px 20px 0 20px;
  436. }
  437. </style>