index.vue 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  1. <template>
  2. <zj-tab-page ref="tabPage" :defaultActives="[{ key: 'list', label: $route.meta.title + '-列表', essential: true }]">
  3. <template slot-scope="{activeKey, data}">
  4. <div :style="{
  5. width: '100%',
  6. height: activeKey == 'list' ? '100%' : '0px',
  7. overflow: 'hidden'
  8. }">
  9. <template-page ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents"
  10. :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
  11. :exportList="exportList" :operation="operation()">
  12. </template-page>
  13. </div>
  14. <div v-if="~['add', 'detail'].indexOf(activeKey)" style="box-sizing: border-box;padding: 16px;">
  15. <el-tabs v-if="activeKey == 'detail'" v-model="activeType_e">
  16. <el-tab-pane label="基础资料" name="jbzl"></el-tab-pane>
  17. <el-tab-pane label="修改记录" name="xgjl"></el-tab-pane>
  18. </el-tabs>
  19. <br v-if="activeKey == 'detail'" />
  20. <div v-if="activeType_e == 'jbzl'">
  21. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  22. <zj-form-module :title="data.label" :showPackUp="false" :form-data="formData" :form-items="formItems">
  23. </zj-form-module>
  24. <zj-form-module title="" label-width="100px" :form-data="formData" :form-items="formItems2">
  25. <el-tabs slot="header" v-model="activeName">
  26. <el-tab-pane :disabled="isEditIndex > -1 ? true : false" label="辅材配置" name="items_m"></el-tab-pane>
  27. <el-tab-pane :disabled="isEditIndex > -1 ? true : false" label="配件配置" name="items_p"></el-tab-pane>
  28. </el-tabs>
  29. </zj-form-module>
  30. </zj-form-container>
  31. <div slot="footer" class="dialog-footer">
  32. <el-button size="mini" @click="data.removeTab">取 消</el-button>
  33. <el-button size="mini" type="primary" @click="quedingbaocun(data.removeTab)">确定</el-button>
  34. </div>
  35. </div>
  36. <div v-if="activeType_e == 'xgjl'">
  37. <zj-form-container :form-data="formData" :styleSwitch="false">
  38. <zj-form-module title="修改记录" :showPackUp="false" :form-data="formData" :form-items="logList">
  39. </zj-form-module>
  40. </zj-form-container>
  41. </div>
  42. </div>
  43. </template>
  44. </zj-tab-page>
  45. </template>
  46. <script>
  47. import TemplatePage from '@/components/template/template-page-1.vue'
  48. import import_mixin from '@/components/template/import_mixin.js'
  49. import operation_mixin from '@/components/template/operation_mixin.js'
  50. import ImageUpload from '@/components/file-upload'
  51. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  52. import { orderEnginbaseList, orderEnginBaseListExport, orderEnginBaseSave, orderEnginBaseDetail } from "@/api/basicEngineeringData";
  53. import { lbsAmapRegion } from '@/api/common.js'
  54. import geographicalPosi from '@/components/geographicalPosi/index.vue'
  55. import { listPageV2 } from "@/api/auxiliaryFittings/attachmentProfile";
  56. import { materialNormList } from "@/api/auxiliaryPriceManagement";
  57. export default {
  58. components: { TemplatePage, ImageUpload, geographicalPosi },
  59. mixins: [import_mixin, operation_mixin],
  60. data() {
  61. return {
  62. // 表格属性
  63. tableAttributes: {
  64. // 启用勾选列
  65. selectColumn: false
  66. },
  67. // 表格事件
  68. tableEvents: {
  69. 'selection-change': this.selectionChange
  70. },
  71. // 勾选选中行
  72. recordSelected: [],
  73. activeName: 'items_m',
  74. formData: {
  75. companyWechatName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  76. projectName: "",
  77. projectNo: "",
  78. manger: "",
  79. mobile: "",
  80. startTime: "",
  81. endTime: "",
  82. provinceId: "",
  83. cityId: "",
  84. areaId: "",
  85. streetId: "",
  86. address: "",
  87. remark: "",
  88. items_m: [],
  89. items_p: [],
  90. },
  91. provinceList: [],
  92. cityList: [],
  93. areaList: [],
  94. streetList: [],
  95. fucaiSel: [],
  96. peijianSel: [],
  97. isEditIndex: -1,
  98. activeType_e: 'jbzl'
  99. }
  100. },
  101. computed: {
  102. // 更多参数
  103. moreParameters() {
  104. return []
  105. },
  106. // 事件组合
  107. optionsEvensGroup() {
  108. return [
  109. [
  110. [
  111. this.optionsEvensAuth('add', {
  112. click: () => {
  113. this.$refs.tabPage.addTab({
  114. // 对应显示的模块
  115. activeKey: "add",
  116. // 唯一标识
  117. key: "add",
  118. // 页签名称
  119. label: "新增",
  120. // 打开时事件
  121. triggerEvent: () => {
  122. this.activeType_e = 'jbzl'
  123. this.handleClose()
  124. this.$nextTick(() => {
  125. this.getinitlbslist()
  126. this.openForm()
  127. })
  128. },
  129. // 关闭时事件
  130. closeEvent: () => { }
  131. })
  132. }
  133. })
  134. ]
  135. ]
  136. ]
  137. },
  138. formItems() {
  139. return [
  140. {
  141. name: 'el-input',
  142. md: 12,
  143. attributes: {
  144. placeholder: '请输入',
  145. disabled: true
  146. },
  147. formItemAttributes: {
  148. label: '所属商户',
  149. prop: 'companyWechatName',
  150. }
  151. },
  152. {
  153. name: 'el-input',
  154. md: 12,
  155. attributes: {
  156. placeholder: '请输入'
  157. },
  158. formItemAttributes: {
  159. label: '工程名称',
  160. prop: 'projectName',
  161. rules: [...required],
  162. }
  163. },
  164. {
  165. name: 'el-input',
  166. md: 6,
  167. attributes: {
  168. placeholder: '请输入'
  169. },
  170. formItemAttributes: {
  171. label: '工程编号',
  172. prop: 'projectNo',
  173. rules: [...required],
  174. }
  175. },
  176. {
  177. name: 'el-input',
  178. md: 6,
  179. attributes: {
  180. placeholder: '请输入'
  181. },
  182. formItemAttributes: {
  183. label: '负责人',
  184. prop: 'manger',
  185. rules: [...required],
  186. }
  187. },
  188. {
  189. name: 'el-input',
  190. md: 6,
  191. attributes: {
  192. placeholder: '请输入'
  193. },
  194. formItemAttributes: {
  195. label: '联系电话',
  196. prop: 'mobile',
  197. rules: [...mobileRequired],
  198. }
  199. },
  200. {
  201. name: 'slot-component',
  202. md: 6,
  203. formItemAttributes: {
  204. label: '项目时间',
  205. prop: 'startTime',
  206. rules: [...required],
  207. },
  208. render: (h, { props }) => {
  209. return (
  210. <div style={{
  211. 'display': 'flex',
  212. 'justify-content': 'space-between'
  213. }}>
  214. <div style="width:49%">
  215. <el-date-picker
  216. style="width:100%"
  217. value={this.formData.startTime}
  218. onInput={(val) => { this.formData.startTime = val }}
  219. value-format="yyyy-MM-dd HH:mm:ss"
  220. type="datetime"
  221. placeholder="选择日期">
  222. </el-date-picker>
  223. </div>
  224. <div style="width:49%">
  225. <el-date-picker
  226. disabled={true}
  227. style="width:100%"
  228. value={this.formData.endTime}
  229. onInput={(val) => { this.formData.endTime = val }}
  230. value-format="yyyy-MM-dd HH:mm:ss"
  231. type="datetime"
  232. placeholder="选择日期">
  233. </el-date-picker>
  234. </div>
  235. </div>
  236. )
  237. }
  238. },
  239. {
  240. name: 'el-select',
  241. md: 6,
  242. formItemAttributes: {
  243. label: '项目地址', //省
  244. prop: 'provinceId',
  245. errLabel: '省',
  246. rules: [...required],
  247. },
  248. options: this.provinceList.map((v, i) => ({ value: v.id, label: v.name })),
  249. attributes: { disabled: false, clearable: true, filterable: true, placeholder: '请选择' },
  250. events: {
  251. change: (val) => {
  252. // 获取省名称
  253. this.formData.province = this.provinceList.find(item => item.id === val)?.name || ''
  254. // 清除市区街道以及详细地址数据
  255. this.delDataK(1)
  256. lbsAmapRegion({ pid: val }).then(res => {
  257. this.cityList = res.data
  258. })
  259. }
  260. }
  261. },
  262. {
  263. name: 'el-select',
  264. md: 5,
  265. formItemAttributes: {
  266. 'label-width': '0px',
  267. label: '', //市
  268. prop: 'cityId',
  269. errLabel: '市',
  270. rules: [...required],
  271. },
  272. options: this.cityList.map((v, i) => ({ value: v.id, label: v.name })),
  273. attributes: { disabled: false, clearable: true, filterable: true, placeholder: '请选择' },
  274. events: {
  275. change: (val) => {
  276. // 获取市名称
  277. this.formData.city = this.cityList.find(item => item.id === val).name
  278. // 清除区街道以及详细地址数据
  279. this.delDataK(2)
  280. lbsAmapRegion({ pid: val }).then(res => {
  281. this.areaList = res.data
  282. })
  283. }
  284. }
  285. },
  286. {
  287. name: 'el-select',
  288. md: 5,
  289. formItemAttributes: {
  290. 'label-width': '0px',
  291. label: '', //区
  292. prop: 'areaId',
  293. errLabel: '区',
  294. rules: [...required],
  295. },
  296. options: this.areaList.map((v, i) => ({ value: v.id, label: v.name })),
  297. attributes: { disabled: false, clearable: true, filterable: true, placeholder: '请选择' },
  298. events: {
  299. change: (val) => {
  300. // 获取区名称
  301. this.formData.area = this.areaList.find(item => item.id === val).name
  302. // 清除街道以及详细地址数据
  303. this.delDataK(3)
  304. lbsAmapRegion({ pid: val }).then(res => {
  305. this.streetList = res.data
  306. })
  307. }
  308. }
  309. },
  310. {
  311. name: 'el-select',
  312. md: 5,
  313. formItemAttributes: {
  314. 'label-width': '0px',
  315. label: '', //街道
  316. prop: 'streetId',
  317. errLabel: '街道',
  318. rules: [...required],
  319. },
  320. options: this.streetList.map((v, i) => ({ value: v.id, label: v.name })),
  321. attributes: { disabled: false, clearable: true, filterable: true, placeholder: '请选择' },
  322. events: {
  323. change: (val) => {
  324. // 获取街道名称
  325. this.formData.street = this.streetList.find(item => item.id === val).name
  326. // 清除详细地址数据
  327. this.delDataK(4)
  328. }
  329. }
  330. },
  331. {
  332. name: 'slot-component',
  333. md: 3,
  334. formItemAttributes: {
  335. 'label-width': '0px',
  336. prop: '',
  337. },
  338. render: (h, { props }) => {
  339. return (
  340. <geographicalPosi
  341. formData={this.formData}
  342. onSelectPosi={data => {
  343. // 获取经纬度
  344. this.formData.lng = data.center[0]
  345. this.formData.lat = data.center[1]
  346. // 获取定位的省市区街道
  347. var { province, city, district, township } = data.data.addressComponent
  348. // 获取选中省名称id
  349. var { id, name } = this.provinceList.find(item => item.name === province)
  350. this.formData.provinceId = id
  351. this.formData.province = name
  352. // 请求市选项
  353. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  354. // 赋值市选项
  355. this.cityList = res.data
  356. // 获取选中市名称id
  357. var { id, name } = res.data.find(item => item.name === city)
  358. this.formData.cityId = id
  359. this.formData.city = name
  360. // 请求区选项
  361. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  362. // 赋值区选项
  363. this.areaList = res.data
  364. // 获取选中区名称id
  365. var { id, name } = res.data.find(item => item.name === district)
  366. this.formData.areaId = id
  367. this.formData.area = name
  368. // 请求街道选项
  369. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  370. // 赋值街道选项
  371. this.streetList = res.data
  372. // 获取选中街道名称id
  373. var { id, name } = res.data.find(item => item.name === township)
  374. this.formData.streetId = id
  375. this.formData.street = name
  376. this.formData.address = data.name
  377. })
  378. })
  379. })
  380. }}
  381. />
  382. )
  383. }
  384. }, {
  385. name: 'el-input',
  386. md: 24,
  387. formItemAttributes: { label: '详细地址', prop: 'address', rules: [...required] },
  388. attributes: { placeholder: '详细地址' }
  389. }, {
  390. name: 'el-input',
  391. md: 24,
  392. attributes: {
  393. type: 'textarea',
  394. rows: 3,
  395. placeholder: '请输入'
  396. },
  397. formItemAttributes: {
  398. label: '项目说明',
  399. prop: 'remark',
  400. }
  401. }
  402. ]
  403. },
  404. formItems2() {
  405. return [
  406. {
  407. md: 24,
  408. isShow: true,
  409. name: 'slot-component',
  410. formItemAttributes: {
  411. label: '',
  412. prop: '',
  413. 'label-width': '0px'
  414. },
  415. render: (h, { props, onInput }) => {
  416. var { value } = props
  417. return (
  418. <div>
  419. {this.activeName == 'items_m'
  420. ? [
  421. <div style="margin-bottom:10px">
  422. <el-button type="primary" onClick={() => { this.addItem("M") }}>
  423. 添加
  424. </el-button>
  425. </div>,
  426. <zj-table
  427. columns={[
  428. {
  429. columnAttributes: {
  430. label: '大类',
  431. prop: 'parentCategoryId',
  432. propName: 'parentCategoryName',
  433. width: 160
  434. },
  435. render: (h, { row, column, index }) => {
  436. return this.isEditIndex == index ? (
  437. <div class="redbordererr">
  438. <el-form-item
  439. label=""
  440. lebel-width="0px"
  441. prop={`${this.activeName}.${index}.${column.columnAttributes.prop}`}
  442. rules={required}
  443. >
  444. <el-select
  445. filterable={true}
  446. value={row[column.columnAttributes.prop]}
  447. onInput={val => {
  448. row[column.columnAttributes.prop] = val
  449. }}
  450. onChange={val => {
  451. if (val) {
  452. row[column.columnAttributes.propName] = this.arrQC(this.fucaiSel, { value: 'parentCategoryId', label: 'parentCategoryName' }).find(item => item.value == val)?.label || ""
  453. } else {
  454. row[column.columnAttributes.propName] = ''
  455. }
  456. this.delItemKey(1, row)
  457. }}
  458. placeholder="请选择"
  459. >
  460. {
  461. this.arrQC(this.fucaiSel, { value: 'parentCategoryId', label: 'parentCategoryName' }).map((item, index_) => (
  462. <el-option key={index_} label={item.label} value={item.value}></el-option>
  463. ))
  464. }
  465. </el-select>
  466. </el-form-item>
  467. </div>
  468. ) : (
  469. <div style="padding:0 6px">{row[column.columnAttributes.propName]}</div>
  470. )
  471. }
  472. },
  473. {
  474. columnAttributes: {
  475. label: '小类',
  476. prop: 'goodsCategoryId',
  477. propName: 'goodsCategoryName',
  478. width: 160
  479. },
  480. render: (h, { row, column, index }) => {
  481. return this.isEditIndex == index ? (
  482. <div class="redbordererr">
  483. <el-form-item
  484. label=""
  485. lebel-width="0px"
  486. prop={`${this.activeName}.${index}.${column.columnAttributes.prop}`}
  487. rules={required}
  488. >
  489. <el-select
  490. filterable={true}
  491. value={row[column.columnAttributes.prop]}
  492. onInput={val => {
  493. row[column.columnAttributes.prop] = val
  494. }}
  495. onChange={val => {
  496. if (val) {
  497. row[column.columnAttributes.propName] = this.arrQC(this.fucaiSel.filter(item => item.parentCategoryId === row.parentCategoryId), { value: 'goodsCategoryId', label: 'categoryName' }).find(item => item.value == val)?.label || ""
  498. } else {
  499. row[column.columnAttributes.propName] = ''
  500. }
  501. this.delItemKey(2, row)
  502. }}
  503. placeholder="请选择"
  504. >
  505. {
  506. this.arrQC(this.fucaiSel.filter(item => item.parentCategoryId === row.parentCategoryId), { value: 'goodsCategoryId', label: 'categoryName' }).map((item, index_) => (
  507. <el-option key={index_} label={item.label} value={item.value}></el-option>
  508. ))
  509. }
  510. </el-select>
  511. </el-form-item>
  512. </div>
  513. ) : (
  514. <div style="padding:0 6px">{row[column.columnAttributes.propName]}</div>
  515. )
  516. }
  517. },
  518. {
  519. columnAttributes: {
  520. label: '辅材名称',
  521. prop: 'goodsId',
  522. propName: 'goodsName',
  523. width: 160
  524. },
  525. render: (h, { row, column, index }) => {
  526. return this.isEditIndex == index ? (
  527. <div class="redbordererr">
  528. <el-form-item
  529. label=""
  530. lebel-width="0px"
  531. prop={`${this.activeName}.${index}.${column.columnAttributes.prop}`}
  532. rules={required}
  533. >
  534. <el-select
  535. filterable={true}
  536. value={row[column.columnAttributes.prop]}
  537. onInput={val => {
  538. row[column.columnAttributes.prop] = val
  539. }}
  540. onChange={val => {
  541. this.delItemKey(3, row)
  542. if (val) {
  543. var data = this.arrQC(this.fucaiSel.filter(item => item.parentCategoryId === row.parentCategoryId && item.goodsCategoryId === row.goodsCategoryId), { value: 'goodsId', label: 'goodsName' }).find(item => item.value == val)
  544. row[column.columnAttributes.propName] = data?.label || ""
  545. if (data) {
  546. row.goodsCode = data?.data?.goodsCode
  547. row.goodsSpecification = data?.data?.goodsSpecification
  548. row.normType = "M"
  549. row.goodsStockUnit = data?.data?.goodsStockUnit
  550. }
  551. } else {
  552. row[column.columnAttributes.propName] = ''
  553. }
  554. }}
  555. placeholder="请选择"
  556. >
  557. {
  558. this.arrQC(this.fucaiSel.filter(item => item.parentCategoryId === row.parentCategoryId && item.goodsCategoryId === row.goodsCategoryId), { value: 'goodsId', label: 'goodsName' }).map((item, index_) => (
  559. <el-option key={index_} label={item.label} value={item.value}></el-option>
  560. ))
  561. }
  562. </el-select>
  563. </el-form-item>
  564. </div>
  565. ) : (
  566. <div style="padding:0 6px">{row[column.columnAttributes.propName]}</div>
  567. )
  568. }
  569. },
  570. {
  571. columnAttributes: {
  572. label: '商品代码',
  573. prop: 'goodsCode',
  574. width: 160
  575. }
  576. },
  577. {
  578. columnAttributes: {
  579. label: '规格型号',
  580. prop: 'goodsSpecification',
  581. width: 160
  582. }
  583. },
  584. {
  585. columnAttributes: {
  586. label: '单位',
  587. prop: 'goodsStockUnit',
  588. width: 160
  589. }
  590. },
  591. {
  592. columnAttributes: {
  593. label: '收费类型',
  594. prop: 'normType',
  595. width: 160
  596. },
  597. render: (h, { row, column, index }) => {
  598. return <div style="padding:0 6px">{({ M: '物料收费', S: '服务收费' })[row[column.columnAttributes.prop]] || ''}</div>
  599. }
  600. },
  601. ...this.commonColumns
  602. ]}
  603. tableData={this.formData.items_m}
  604. tableAttributes={{
  605. size: 'mini',
  606. border: true
  607. }}
  608. />
  609. ]
  610. : this.activeName == 'items_p'
  611. ? [
  612. <div style="margin-bottom:10px">
  613. <el-button type="primary" onClick={() => { this.addItem("P") }}>
  614. 添加
  615. </el-button>
  616. </div>,
  617. <zj-table
  618. columns={[
  619. {
  620. columnAttributes: {
  621. label: '配件名称',
  622. prop: 'goodsId',
  623. propName: 'goodsName',
  624. width: 160
  625. },
  626. render: (h, { row, column, index }) => {
  627. return this.isEditIndex == index ? (
  628. <div class="redbordererr">
  629. <el-form-item
  630. label=""
  631. lebel-width="0px"
  632. prop={`${this.activeName}.${index}.${column.columnAttributes.prop}`}
  633. rules={required}
  634. >
  635. <el-select
  636. filterable={true}
  637. value={row[column.columnAttributes.prop]}
  638. onInput={val => {
  639. row[column.columnAttributes.prop] = val
  640. }}
  641. onChange={val => {
  642. this.delItemKey(3, row)
  643. if (val) {
  644. var data = this.peijianSel.find(item => item.goodsId == val)
  645. row[column.columnAttributes.propName] = data?.goodsName || ""
  646. if (data) {
  647. row.goodsStockUnit = data.goodsStockUnit
  648. row.goodsCode = data.goodsCode
  649. row.normType = data.normType
  650. row.brandRelaName = data.brandRelaName
  651. row.productRelaName = data.productRelaName
  652. }
  653. } else {
  654. row[column.columnAttributes.propName] = ''
  655. }
  656. }}
  657. placeholder="请选择"
  658. >
  659. {this.peijianSel.map((item, index_) => (
  660. <el-option key={index_} label={item.goodsName} value={item.goodsId}></el-option>
  661. ))}
  662. </el-select>
  663. </el-form-item>
  664. </div>
  665. ) : (
  666. <div style="padding:0 6px">{row[column.columnAttributes.propName]}</div>
  667. )
  668. }
  669. },
  670. {
  671. columnAttributes: {
  672. label: '单位',
  673. prop: 'goodsStockUnit',
  674. width: 160
  675. }
  676. },
  677. {
  678. columnAttributes: {
  679. label: '商品代码',
  680. prop: 'goodsCode',
  681. width: 160
  682. }
  683. },
  684. {
  685. columnAttributes: {
  686. label: '收费类型',
  687. prop: 'normType',
  688. width: 160
  689. },
  690. render: (h, { row, column, index }) => {
  691. return <div style="padding:0 6px">{({ M: '物料收费', S: '服务收费' })[row[column.columnAttributes.prop]] || ''}</div>
  692. }
  693. },
  694. {
  695. columnAttributes: {
  696. label: '适用品牌',
  697. prop: 'brandRelaName',
  698. width: 160
  699. }
  700. },
  701. {
  702. columnAttributes: {
  703. label: '适用产品大类',
  704. prop: 'productRelaName',
  705. width: 160
  706. }
  707. },
  708. ...this.commonColumns
  709. ]}
  710. tableData={this.formData.items_p}
  711. tableAttributes={{
  712. size: 'mini',
  713. border: true
  714. }}
  715. />
  716. ]
  717. : null}
  718. </div>
  719. )
  720. }
  721. }
  722. ]
  723. },
  724. commonColumns() {
  725. return [{
  726. columnAttributes: {
  727. label: '销售价格(元)',
  728. prop: 'normAmount',
  729. },
  730. render: (h, { row, column, index }) => {
  731. return this.isEditIndex == index ? (
  732. <div class="redbordererr">
  733. <el-form-item
  734. label=""
  735. lebel-width="0px"
  736. prop={`${this.activeName}.${index}.${column.columnAttributes.prop}`}
  737. rules={required}
  738. >
  739. <el-input
  740. value={row[column.columnAttributes.prop]}
  741. onInput={val => {
  742. row[column.columnAttributes.prop] = val
  743. }}
  744. type="number"
  745. placeholder="请输入"
  746. ></el-input>
  747. </el-form-item>
  748. </div>
  749. ) : (
  750. <div style="padding:0 6px">{row[column.columnAttributes.prop]}</div>
  751. )
  752. }
  753. },
  754. // {
  755. // columnAttributes: {
  756. // label: '师傅分账金额(元)',
  757. // prop: 'workerAmount',
  758. // width: 160
  759. // },
  760. // render: (h, { row, column, index }) => {
  761. // return this.isEditIndex == index ? (
  762. // <div class="redbordererr">
  763. // <el-form-item
  764. // label=""
  765. // lebel-width="0px"
  766. // prop={`${this.activeName}.${index}.${column.columnAttributes.prop}`}
  767. // rules={required}
  768. // >
  769. // <el-input
  770. // value={row[column.columnAttributes.prop]}
  771. // onInput={val => {
  772. // row[column.columnAttributes.prop] = val
  773. // }}
  774. // type="number"
  775. // placeholder="请输入"
  776. // ></el-input>
  777. // </el-form-item>
  778. // </div>
  779. // ) : (
  780. // <div style="padding:0 6px">{row[column.columnAttributes.prop]}</div>
  781. // )
  782. // }
  783. // }, {
  784. // columnAttributes: {
  785. // label: '商户分账金额(元)',
  786. // prop: 'websitAmount',
  787. // width: 160
  788. // },
  789. // render: (h, { row, column, index }) => {
  790. // return this.isEditIndex == index ? (
  791. // <div class="redbordererr">
  792. // <el-form-item
  793. // label=""
  794. // lebel-width="0px"
  795. // prop={`${this.activeName}.${index}.${column.columnAttributes.prop}`}
  796. // rules={required}
  797. // >
  798. // <el-input
  799. // value={row[column.columnAttributes.prop]}
  800. // onInput={val => {
  801. // row[column.columnAttributes.prop] = val
  802. // }}
  803. // type="number"
  804. // placeholder="请输入"
  805. // ></el-input>
  806. // </el-form-item>
  807. // </div>
  808. // ) : (
  809. // <div style="padding:0 6px">{row[column.columnAttributes.prop]}</div>
  810. // )
  811. // }
  812. // },
  813. {
  814. columnAttributes: {
  815. label: '操作',
  816. fixed: 'right',
  817. width: 140
  818. },
  819. render: (h, { row, column, index }) => {
  820. return (
  821. <div style="padding:0 6px" class="operation-btns">
  822. {[
  823. this.isEditIndex == index ? (
  824. <el-button
  825. type="text"
  826. onClick={() => { this.verifyBtn() }}
  827. >
  828. 确认
  829. </el-button>
  830. ) : null,
  831. this.isEditIndex == -1 ? (
  832. <el-button
  833. type="text"
  834. onClick={() => { this.isEditIndex = index }}
  835. >
  836. 编辑
  837. </el-button>
  838. ) : null,
  839. <el-button
  840. type="text"
  841. onClick={() => {
  842. this.formData?.[this.activeName]?.splice(index, 1)
  843. if (index == this.isEditIndex) {
  844. this.isEditIndex = -1
  845. }
  846. }}
  847. >
  848. 删除
  849. </el-button>
  850. ]}
  851. </div>
  852. )
  853. }
  854. }]
  855. },
  856. logList() {
  857. return [
  858. {
  859. md: 24,
  860. isShow: true,
  861. name: 'slot-component',
  862. formItemAttributes: {
  863. label: '',
  864. prop: '',
  865. 'label-width': '0px'
  866. },
  867. render: (h, { props, onInput }) => {
  868. var { value } = props
  869. return (
  870. <zj-table
  871. columns={[
  872. {
  873. columnAttributes: {
  874. label: '操作类型',
  875. prop: 'typeText',
  876. }
  877. },
  878. {
  879. columnAttributes: {
  880. label: '操作内容',
  881. prop: 'content',
  882. }
  883. },
  884. {
  885. columnAttributes: {
  886. label: '操作人',
  887. prop: 'createBy',
  888. }
  889. },
  890. {
  891. columnAttributes: {
  892. label: '操作时间',
  893. prop: 'createTime',
  894. }
  895. },
  896. ]}
  897. tableData={this.formData.operatorLogList}
  898. tableAttributes={{
  899. size: 'mini',
  900. border: true
  901. }}
  902. />
  903. )
  904. }
  905. }
  906. ]
  907. },
  908. },
  909. methods: {
  910. // 列表请求函数
  911. getList: orderEnginbaseList,
  912. // 列表导出函数
  913. exportList: orderEnginBaseListExport,
  914. // 表格列解析渲染数据更改
  915. columnParsing(item, defaultData) {
  916. return defaultData
  917. },
  918. // 监听勾选变化
  919. selectionChange(data) {
  920. this.recordSelected = data
  921. },
  922. handleClose() {
  923. this.$refs?.formRef?.resetFields()
  924. this.$data.formData = this.$options.data().formData
  925. this.activeName = 'items_m'
  926. },
  927. // 打开弹窗
  928. openForm() {
  929. this.isEditIndex = -1
  930. // 获取辅材下拉数据
  931. materialNormList({ "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.status", "compare": "=", "value": "ON" }] }).then(res => {
  932. this.fucaiSel = res.data.records
  933. });
  934. // 获取配件下拉数据
  935. listPageV2({ "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.status", "compare": "=", "value": "ON" }, { "param": "a.norm_type", "compare": "=", "value": "M" }] }).then(res => {
  936. this.peijianSel = res.data.records
  937. });
  938. },
  939. quedingbaocun(removeTab) {
  940. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  941. if (valid) {
  942. orderEnginBaseSave({
  943. ...this.formData,
  944. items: [...this.formData.items_m, ...this.formData.items_p]
  945. }).then(res => {
  946. this.$message({
  947. type: 'success',
  948. message: '保存成功'
  949. })
  950. this.handleClose()
  951. this.$refs.pageRef.refreshList()
  952. removeTab && removeTab()
  953. })
  954. }
  955. })
  956. },
  957. // 操作按钮
  958. operation() {
  959. return this.operationBtn({
  960. detail: {
  961. click: ({ row, index, column }) => {
  962. this.$refs.tabPage.addTab({
  963. // 对应显示的模块
  964. activeKey: "detail",
  965. // 唯一标识
  966. key: "detail",
  967. // 页签名称
  968. label: "详情",
  969. // 打开时事件
  970. triggerEvent: () => {
  971. this.activeType_e = 'jbzl'
  972. this.handleClose()
  973. this.$nextTick(() => {
  974. orderEnginBaseDetail({ id: row.id }).then(res => {
  975. Object.assign(this.formData, res.data, {
  976. items_m: (res.data.items || []).filter(item => item.goodsType == "M"),
  977. items_p: (res.data.items || []).filter(item => item.goodsType == "P"),
  978. })
  979. this.getinitlbslist()
  980. this.openForm()
  981. })
  982. })
  983. },
  984. // 关闭时事件
  985. closeEvent: () => { }
  986. })
  987. }
  988. },
  989. orderDetail: {
  990. click: ({ row, index, column }) => {
  991. this.$router.push({
  992. name: 'workOrderPool',
  993. params: {
  994. pageName: row.projectNo,
  995. pageType: 'projectNo',
  996. pageCode: row.projectNo,
  997. },
  998. })
  999. }
  1000. }
  1001. })
  1002. },
  1003. // 获取省市区街道
  1004. getinitlbslist() {
  1005. // 初始化请求省市区街道下拉选项数据
  1006. lbsAmapRegion({ pid: 0 }).then(res => {
  1007. this.provinceList = res.data
  1008. if (this.formData.provinceId) {
  1009. var item = this.provinceList.find(item => item.name === this.formData.provinceId)
  1010. if (item) {
  1011. this.formData.province = item.name
  1012. }
  1013. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  1014. this.cityList = res.data
  1015. if (this.formData.cityId) {
  1016. var item2 = this.cityList.find(item => item.name === this.formData.cityId)
  1017. if (item2) {
  1018. this.formData.city = item2.name
  1019. }
  1020. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  1021. this.areaList = res.data
  1022. if (this.formData.areaId) {
  1023. var item3 = this.areaList.find(item => item.name === this.formData.areaId)
  1024. if (item3) {
  1025. this.formData.city = item2.name
  1026. }
  1027. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  1028. this.streetList = res.data
  1029. if (this.formData.streetId) {
  1030. var item4 = this.streetList.find(item => item.name === this.formData.streetId)
  1031. if (item4) {
  1032. this.formData.street = item4.name
  1033. }
  1034. }
  1035. })
  1036. }
  1037. })
  1038. }
  1039. })
  1040. }
  1041. })
  1042. },
  1043. delDataK(num) {
  1044. if (num <= 1) {
  1045. // 删除市
  1046. this.formData.cityId = ''
  1047. this.formData.city = ''
  1048. // 删除市选项
  1049. this.cityList = []
  1050. }
  1051. if (num <= 2) {
  1052. // 删除区
  1053. this.formData.areaId = ''
  1054. this.formData.area = ''
  1055. // 删除区选项
  1056. this.areaList = []
  1057. }
  1058. if (num <= 3) {
  1059. // 删除街道
  1060. this.formData.streetId = ''
  1061. this.formData.street = ''
  1062. // 删除街道选项
  1063. this.streetList = []
  1064. }
  1065. // 删除gps地址
  1066. this.formData.address = ''
  1067. },
  1068. delItemKey(num, row) {
  1069. if (num <= 1) {
  1070. row.goodsCategoryId = ""
  1071. row.goodsCategoryName = ""
  1072. }
  1073. if (num <= 2) {
  1074. row.goodsId = ""
  1075. row.goodsName = ""
  1076. }
  1077. if (num <= 3) {
  1078. row.brandRelaId = ""
  1079. row.brandRelaName = ""
  1080. row.goodsBarcodeId = ""
  1081. row.goodsCode = ""
  1082. row.goodsSpecification = ""
  1083. row.goodsStockUnit = ""
  1084. row.normType = ""
  1085. row.orderEnginBaseId = ""
  1086. row.productCreateBy = ""
  1087. row.productCreateTime = ""
  1088. row.productRelaId = ""
  1089. row.productRelaName = ""
  1090. row.productUpdateBy = ""
  1091. row.productUpdateTime = ""
  1092. }
  1093. },
  1094. arrQC(list, qz = { label: '', value: '' }) {
  1095. var obj = {}
  1096. for (var item of list) {
  1097. obj[item[qz?.value || 'value']] = item
  1098. }
  1099. return Object.keys(obj).map(key => {
  1100. return {
  1101. data: obj[key],
  1102. value: key,
  1103. label: obj[key][qz?.label || 'label']
  1104. }
  1105. })
  1106. },
  1107. addItem(goodsType) {
  1108. if (this.isEditIndex > -1) {
  1109. this.$refs.formRef.validateField(this.getVfyKey(this.isEditIndex), (valid, invalidFields, errLabels) => {
  1110. if (valid) {
  1111. this.formData[this.activeName].unshift({
  1112. "brandRelaId": "",
  1113. "brandRelaName": "",
  1114. "goodsBarcodeId": "",
  1115. "goodsCategoryId": "",
  1116. "goodsCategoryName": "",
  1117. "goodsCode": "",
  1118. "goodsId": "",
  1119. "goodsName": "",
  1120. "goodsSpecification": "",
  1121. "goodsStockUnit": "",
  1122. "goodsType": goodsType,
  1123. "normAmount": '',
  1124. "normType": "",
  1125. "orderEnginBaseId": "",
  1126. "parentCategoryId": "",
  1127. "parentCategoryName": "",
  1128. "productCreateBy": "",
  1129. "productCreateTime": "",
  1130. "productRelaId": "",
  1131. "productRelaName": "",
  1132. "productUpdateBy": "",
  1133. "productUpdateTime": "",
  1134. // "websitAmount": '',
  1135. // "workerAmount": ''
  1136. })
  1137. this.isEditIndex = 0
  1138. }
  1139. })
  1140. } else {
  1141. this.formData[this.activeName].unshift({
  1142. "brandRelaId": "",
  1143. "brandRelaName": "",
  1144. "goodsBarcodeId": "",
  1145. "goodsCategoryId": "",
  1146. "goodsCategoryName": "",
  1147. "goodsCode": "",
  1148. "goodsId": "",
  1149. "goodsName": "",
  1150. "goodsSpecification": "",
  1151. "goodsStockUnit": "",
  1152. "goodsType": goodsType,
  1153. "normAmount": '',
  1154. "normType": "",
  1155. "orderEnginBaseId": "",
  1156. "parentCategoryId": "",
  1157. "parentCategoryName": "",
  1158. "productCreateBy": "",
  1159. "productCreateTime": "",
  1160. "productRelaId": "",
  1161. "productRelaName": "",
  1162. "productUpdateBy": "",
  1163. "productUpdateTime": "",
  1164. // "websitAmount": '',
  1165. // "workerAmount": ''
  1166. })
  1167. this.isEditIndex = 0
  1168. }
  1169. },
  1170. getVfyKey() {
  1171. return [
  1172. `${this.activeName}.${this.isEditIndex}.parentCategoryId`,
  1173. `${this.activeName}.${this.isEditIndex}.goodsCategoryId`,
  1174. `${this.activeName}.${this.isEditIndex}.goodsId`,
  1175. `${this.activeName}.${this.isEditIndex}.normAmount`,
  1176. // `${this.activeName}.${this.isEditIndex}.workerAmount`,
  1177. // `${this.activeName}.${this.isEditIndex}.websitAmount`,
  1178. ]
  1179. },
  1180. verifyBtn() {
  1181. this.$refs.formRef.validateField(this.getVfyKey(this.isEditIndex), (valid, invalidFields, errLabels) => {
  1182. if (valid) {
  1183. this.isEditIndex = -1
  1184. }
  1185. })
  1186. }
  1187. }
  1188. }
  1189. </script>
  1190. <style lang="scss" scoped></style>