approve.vue 75 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383
  1. <template>
  2. <div class="app-container">
  3. <el-dialog
  4. :title="upload.title"
  5. :visible.sync="upload.open"
  6. width="400px"
  7. append-to-body
  8. >
  9. <el-upload
  10. ref="upload"
  11. :limit="1"
  12. accept=".xlsx, .xls"
  13. :headers="upload.headers"
  14. :action="
  15. upload.url +
  16. '?updateSupport=' +
  17. upload.updateSupport +
  18. '&tableName=' +
  19. tableName +
  20. '&sqlKey=' +
  21. tableKey
  22. "
  23. v-loading="upload.isUploading"
  24. :disabled="upload.isUploading"
  25. :on-progress="handleFileUploadProgress"
  26. :on-success="handleFileSuccess"
  27. :auto-upload="false"
  28. :onChange="handleChange"
  29. drag
  30. >
  31. <i class="el-icon-upload"></i>
  32. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  33. <div class="el-upload__tip text-center" slot="tip">
  34. <!-- <div class="el-upload__tip" slot="tip">-->
  35. <!-- <el-checkbox v-model="upload.updateSupport"/>-->
  36. <!-- 是否更新已经存在的用户数据-->
  37. <!-- </div>-->
  38. <span>仅允许导入xls、xlsx格式文件。</span>
  39. <el-link
  40. type="primary"
  41. :underline="false"
  42. style="font-size: 12px; vertical-align: baseline"
  43. @click="importTemplate"
  44. >下载模板
  45. </el-link>
  46. </div>
  47. </el-upload>
  48. <div slot="footer" class="dialog-footer">
  49. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  50. <el-button @click="upload.open = false">取 消</el-button>
  51. </div>
  52. </el-dialog>
  53. <Queryfrom
  54. :form-vals="templateInfo.where"
  55. :statisticList="statisticList"
  56. :showCount="showCount"
  57. :showSearch="showSearch"
  58. @getList="getList"
  59. ref="mychild"
  60. />
  61. <el-radio-group
  62. style="
  63. display: float;
  64. float: right;
  65. margin-right: 100px;
  66. margin-bottom: 10px;
  67. "
  68. v-model="queryParams.conditionMap.columnValue"
  69. size="mini"
  70. @change="approveTypeChange"
  71. >
  72. <el-radio-button label="2">未审批</el-radio-button>
  73. <el-radio-button label="3,4,5,6,7">已审批</el-radio-button>
  74. <el-radio-button label="7">已驳回</el-radio-button>
  75. <!-- <el-radio-button :label="2">生产</el-radio-button> -->
  76. </el-radio-group>
  77. <el-table
  78. v-loading="loading"
  79. :data="tableList"
  80. @selection-change="handleSelectionChange"
  81. ref="tableRef"
  82. :cell-style="cellStyle"
  83. :reserve-selection="true"
  84. :row-key="getRowKey"
  85. >
  86. <el-table-column
  87. type="selection"
  88. width="55"
  89. reserve-selection
  90. align="center"
  91. >
  92. </el-table-column>
  93. <!-- <span v-for="(key, val) in columns" :key="key">
  94. <el-table-column :label="key" align="center" :prop="val" />
  95. </span> -->
  96. <el-table-column
  97. v-for="item in columns"
  98. :key="item.key"
  99. :label="item.value"
  100. align="center"
  101. :prop="item.key"
  102. >
  103. <template slot-scope="scope">
  104. <!-- 存在字段样式或字典样式 -->
  105. <template
  106. v-if="
  107. scope.row.styleFieldObj != undefined &&
  108. scope.row.styleFieldObj[item.key]
  109. "
  110. >
  111. <!-- 字段样式 -->
  112. <template v-if="scope.row.styleFieldObj[item.key].styleType == 1">
  113. <!-- 一般字体样式 -->
  114. <template
  115. v-if="scope.row.styleFieldObj[item.key].fieldStyleType == 0"
  116. >
  117. <span
  118. :style="`color:${
  119. scope.row.styleFieldObj[item.key].fontColor
  120. }`"
  121. >{{ scope.row[item.key] }}</span
  122. >
  123. </template>
  124. <!-- 标签字体样式 -->
  125. <template
  126. v-else-if="
  127. scope.row.styleFieldObj[item.key].fieldStyleType == 1
  128. "
  129. >
  130. <el-tag
  131. :type="scope.row.styleFieldObj[item.key].tagType"
  132. :effect="
  133. scope.row.styleFieldObj[item.key].isTagFullBg
  134. ? 'dark'
  135. : 'light'
  136. "
  137. >
  138. {{ scope.row[item.key] }}
  139. </el-tag>
  140. </template>
  141. </template>
  142. <!-- 字典样式 -->
  143. <template
  144. v-else-if="scope.row.styleFieldObj[item.key].styleType == 2"
  145. >
  146. <span
  147. v-if="
  148. scope.row.styleFieldObj[item.key].listClass == '' ||
  149. scope.row.styleFieldObj[item.key].listClass == 'default'
  150. "
  151. >{{ scope.row.styleFieldObj[item.key].dictLabel }}</span
  152. >
  153. <el-tag
  154. v-else
  155. :type="
  156. scope.row.styleFieldObj[item.key].listClass == 'primary'
  157. ? ''
  158. : scope.row.styleFieldObj[item.key].listClass
  159. "
  160. >{{ scope.row.styleFieldObj[item.key].dictLabel }}</el-tag
  161. >
  162. </template>
  163. </template>
  164. <!-- 显示默认值 -->
  165. <template v-else>
  166. {{ scope.row[item.key] }}
  167. </template>
  168. </template>
  169. </el-table-column>
  170. <el-table-column
  171. v-if="isShowExcuteCol"
  172. label="操作"
  173. align="center"
  174. class-name="small-padding fixed-width"
  175. >
  176. <template slot-scope="scope">
  177. <el-button
  178. type="info"
  179. size="default"
  180. @click="handleEdit(scope.$index, scope.row)"
  181. >审批</el-button
  182. >
  183. <Menu
  184. :row="scope.row"
  185. v-for="btnObj in excuteBtnArr"
  186. :key="btnObj.id"
  187. :listAll="btnObj"
  188. @excuteHandler="excuteHandler"
  189. ></Menu>
  190. </template>
  191. </el-table-column>
  192. </el-table>
  193. <pagination
  194. v-show="total > 0"
  195. :total="total"
  196. :page.sync="queryParams.pageNum"
  197. :limit.sync="queryParams.pageSize"
  198. @pagination="pageList"
  199. />
  200. <!-- 添加或修改销售出库单:- 过磅记录生成数据对话框 -->
  201. <el-dialog :title="title" :visible.sync="open" append-to-body>
  202. <!-- <iframe
  203. :src="iframeUrl"
  204. width="100%"
  205. height="600px"
  206. style="border: none"
  207. scrolling="no"
  208. >
  209. </iframe> -->
  210. <!-- <k-form-build
  211. v-if="jsonData"
  212. class="formBuild"
  213. ref="addFromRef"
  214. :dynamicData="dynamicData"
  215. :defaultValue="defaultValue"
  216. @submit="tempSubBtn"
  217. @change="formChangeHandler"
  218. :value="jsonData"
  219. /> -->
  220. <el-row :gutter="20">
  221. <el-form
  222. :model="formData"
  223. ref="formDataRef"
  224. :rules="rules"
  225. label-width="100px"
  226. :inline="true"
  227. size="normal"
  228. >
  229. <!-- <el-form-item prop="saleNo" label="合同号:">
  230. <el-input size="small" v-model="formData.saleNo"></el-input>
  231. </el-form-item> -->
  232. <el-col :span="12">
  233. <el-form-item prop="saleDate" label="日期:">
  234. <el-date-picker
  235. size="small"
  236. v-model="formData.saleDate"
  237. value-format="yyyy-MM-dd"
  238. type="date"
  239. disabled
  240. placeholder="选择日期"
  241. >
  242. </el-date-picker>
  243. </el-form-item>
  244. </el-col>
  245. <el-col :span="12">
  246. <el-form-item prop="saleCustomNo" label="客户名称:">
  247. <el-select
  248. size="small"
  249. v-model="formData.saleCustomNo"
  250. placeholder="请选择客户"
  251. clearable
  252. disabled
  253. filterable
  254. @change="customChangeHandler"
  255. >
  256. <el-option
  257. v-for="item in customerOptions"
  258. :key="item.customNo"
  259. :label="item.customName"
  260. :value="item.customNo"
  261. >
  262. </el-option>
  263. </el-select>
  264. </el-form-item>
  265. </el-col>
  266. <el-col :span="12">
  267. <el-form-item label="联系人:" size="normal">
  268. {{ formData.contactPerson }}
  269. </el-form-item>
  270. <el-form-item label="客户地址:" size="normal">
  271. {{ formData.customAddress }}
  272. </el-form-item>
  273. <el-form-item label="客户国别:" size="normal">
  274. {{ formData.customCountryType }}
  275. </el-form-item>
  276. </el-col>
  277. <el-col :span="12">
  278. <el-form-item
  279. label-width="120px"
  280. prop="saleDate"
  281. label="预计下单时间:"
  282. >
  283. <el-date-picker
  284. size="small"
  285. disabled
  286. v-model="formData.saleOrderEstimatedTime"
  287. value-format="yyyy-MM-dd"
  288. type="date"
  289. placeholder="选择日期"
  290. >
  291. </el-date-picker>
  292. </el-form-item>
  293. </el-col>
  294. <el-col :span="12">
  295. <el-form-item label="交货周期:" size="normal">
  296. <el-input
  297. disabled
  298. size="small"
  299. v-model="formData.saleLeadTime"
  300. ></el-input>
  301. </el-form-item>
  302. </el-col>
  303. <el-col :span="24">
  304. <el-divider>货品明细</el-divider>
  305. </el-col>
  306. <el-table
  307. :data="productionTableData"
  308. border
  309. show-summary
  310. :summary-method="getSummaries"
  311. sum-text="小计"
  312. style="width: 100%"
  313. >
  314. <el-table-column prop="productName" label="品名" width="180">
  315. <template slot-scope="scope">
  316. <!-- <el-input
  317. v-model="scope.row.productName"
  318. size="small"
  319. clearable
  320. ></el-input> -->
  321. <el-select
  322. v-model="scope.row.productNo"
  323. placeholder=""
  324. clearable
  325. filterable
  326. disabled
  327. >
  328. <el-option
  329. v-for="item in productionOptions"
  330. :key="item.productNo"
  331. :label="item.productName"
  332. :value="item.productNo"
  333. >
  334. </el-option>
  335. </el-select>
  336. </template>
  337. </el-table-column>
  338. <el-table-column prop="productNumber" label="数量/kg">
  339. <template slot-scope="scope">
  340. <el-input
  341. v-model="scope.row.productNumber"
  342. size="small"
  343. disabled
  344. clearable
  345. ></el-input>
  346. </template>
  347. </el-table-column>
  348. <el-table-column prop="productUnitPrice" label="单价">
  349. <template slot-scope="scope">
  350. <el-input
  351. v-model="scope.row.productUnitPrice"
  352. size="small"
  353. disabled
  354. clearable
  355. ></el-input>
  356. </template>
  357. </el-table-column>
  358. <el-table-column prop="productAmounts" label="金额">
  359. <template slot-scope="scope">
  360. <el-input
  361. v-model="scope.row.productAmounts"
  362. size="small"
  363. disabled
  364. clearable
  365. ></el-input>
  366. </template>
  367. </el-table-column>
  368. <el-table-column prop="remark" label="备注">
  369. <template slot-scope="scope">
  370. <el-input
  371. v-model="scope.row.remark"
  372. size="small"
  373. disabled
  374. clearable
  375. ></el-input>
  376. </template>
  377. </el-table-column>
  378. <el-table-column label="操作">
  379. <template slot-scope="scope">
  380. <el-button
  381. type="danger"
  382. size="small"
  383. disabled
  384. @click="deleteProduct(scope.$index)"
  385. >删除</el-button
  386. >
  387. </template>
  388. </el-table-column>
  389. </el-table>
  390. <el-button
  391. class="mt5"
  392. type="primary"
  393. style="width: 100%"
  394. size="small"
  395. disabled
  396. @click="addProduct"
  397. >添加货品</el-button
  398. >
  399. <el-col :span="12">
  400. <el-form-item label-width="120px" label="合计金额(大写)">
  401. <el-input
  402. v-model="formData.saleAmountInWords"
  403. size="small"
  404. disabled
  405. clearable
  406. ></el-input>
  407. </el-form-item>
  408. </el-col>
  409. <el-col :span="12">
  410. <el-form-item label="付款方式">
  411. <el-input
  412. v-model="formData.salePayType"
  413. size="small"
  414. disabled
  415. clearable
  416. ></el-input>
  417. </el-form-item>
  418. </el-col>
  419. <el-col :span="24">
  420. <el-divider>工艺要求</el-divider>
  421. </el-col>
  422. <el-col :span="12">
  423. <el-form-item label="网格:">
  424. <el-input
  425. v-model="formData.craftGrid"
  426. size="small"
  427. disabled
  428. clearable
  429. ></el-input>
  430. </el-form-item>
  431. </el-col>
  432. <el-col :span="12">
  433. <el-form-item label="油剂:">
  434. <el-input
  435. v-model="formData.craftOil"
  436. size="small"
  437. clearable
  438. disabled
  439. ></el-input>
  440. </el-form-item>
  441. </el-col>
  442. <el-col :span="12">
  443. <el-form-item label="卷装:">
  444. <el-input
  445. v-model="formData.craftPackage"
  446. size="small"
  447. clearable
  448. disabled
  449. ></el-input>
  450. </el-form-item>
  451. </el-col>
  452. <el-col :span="12">
  453. <el-form-item label="色牢度:">
  454. <el-input
  455. v-model="formData.craftColorFastness"
  456. size="small"
  457. clearable
  458. disabled
  459. ></el-input>
  460. </el-form-item>
  461. </el-col>
  462. <el-col :span="12">
  463. <el-form-item label="其它:">
  464. <el-input
  465. v-model="formData.craftOther"
  466. size="small"
  467. clearable
  468. disabled
  469. ></el-input>
  470. </el-form-item>
  471. </el-col>
  472. <el-col :span="12">
  473. <el-form-item label="包装/贴唛:">
  474. <el-input
  475. v-model="formData.craftMark"
  476. size="small"
  477. clearable
  478. disabled
  479. ></el-input>
  480. </el-form-item>
  481. </el-col>
  482. <el-col :span="12">
  483. <el-form-item label="运输方式:">
  484. <el-input
  485. v-model="formData.shippingMethod"
  486. size="small"
  487. clearable
  488. disabled
  489. ></el-input>
  490. </el-form-item>
  491. </el-col>
  492. <el-col :span="24">
  493. <el-divider>审计人员数据</el-divider>
  494. </el-col>
  495. <el-col :span="12">
  496. <el-form-item label="业务员:">
  497. <!-- <el-input
  498. v-model="formData.salesman"
  499. size="small"
  500. clearable
  501. ></el-input> -->
  502. {{ nickName }}
  503. </el-form-item>
  504. </el-col>
  505. <!-- <el-col :span="12">
  506. <el-form-item label="业务主管:">
  507. <el-input
  508. v-model="formData.saleLeader"
  509. size="small"
  510. clearable
  511. disabled
  512. ></el-input>
  513. </el-form-item>
  514. </el-col>
  515. <el-col :span="12">
  516. <el-form-item label="财务部:">
  517. <el-input
  518. v-model="formData.finance"
  519. size="small"
  520. clearable
  521. disabled
  522. ></el-input>
  523. </el-form-item>
  524. </el-col>
  525. <el-col :span="12">
  526. <el-form-item label="生产部:">
  527. <el-input
  528. v-model="formData.production"
  529. size="small"
  530. clearable
  531. disabled
  532. ></el-input>
  533. </el-form-item>
  534. </el-col>
  535. <el-col :span="12">
  536. <el-form-item label="批准人:">
  537. <el-input
  538. v-model="formData.saleApprover"
  539. size="small"
  540. clearable
  541. disabled
  542. ></el-input>
  543. </el-form-item>
  544. </el-col> -->
  545. </el-form>
  546. </el-row>
  547. <el-divider>审批</el-divider>
  548. <el-row :gutter="20">
  549. <el-form
  550. :model="approveForm"
  551. ref="approveFormRef"
  552. :rules="approveRule"
  553. label-width="100px"
  554. :inline="false"
  555. size="normal"
  556. >
  557. <el-col :span="12">
  558. <el-form-item label="是否通过:" prop="status">
  559. <el-radio v-model="approveForm.status" label="3">通过</el-radio>
  560. <el-radio v-model="approveForm.status" label="7">不通过</el-radio>
  561. </el-form-item>
  562. </el-col>
  563. <el-col :span="12">
  564. <el-form-item
  565. v-if="approveForm.status == '3'"
  566. label="订单类型:"
  567. size="normal"
  568. prop="orderType"
  569. >
  570. <el-select
  571. v-model="approveForm.orderType"
  572. placeholder="请选择订单类型"
  573. clearable
  574. filterable
  575. >
  576. <el-option
  577. v-for="item in dict.type.sales_order_type"
  578. :key="item.value"
  579. :label="item.label"
  580. :value="item.value"
  581. >
  582. </el-option>
  583. </el-select>
  584. </el-form-item>
  585. </el-col>
  586. <el-col :span="12">
  587. <el-form-item label="业务主管:">
  588. <el-input
  589. v-model="approveForm.saleLeader"
  590. size="small"
  591. clearable
  592. ></el-input>
  593. </el-form-item>
  594. </el-col>
  595. <el-col :span="12">
  596. <el-form-item label="财务部:">
  597. <el-input
  598. v-model="approveForm.finance"
  599. size="small"
  600. clearable
  601. ></el-input>
  602. </el-form-item>
  603. </el-col>
  604. <el-col :span="12">
  605. <el-form-item label="生产部:">
  606. <el-input
  607. v-model="approveForm.production"
  608. size="small"
  609. clearable
  610. ></el-input>
  611. </el-form-item>
  612. </el-col>
  613. </el-form>
  614. </el-row>
  615. <div slot="footer" class="dialog-footer">
  616. <el-button type="primary" @click="approveConfirm">确 定</el-button>
  617. <el-button @click="cancel">取 消</el-button>
  618. </div>
  619. </el-dialog>
  620. <!-- 绑定按钮dialog -->
  621. <el-dialog
  622. title="提示"
  623. :visible.sync="btnDialogVisible"
  624. :before-close="handleClose"
  625. >
  626. <DialogTemplate
  627. ref="dialogRef"
  628. :groupKey="groupKey"
  629. :rowobj="rowobj"
  630. :subCount="subCount"
  631. :tableCount="tableCount"
  632. :subTableName="subTableName"
  633. @addList="addListHandler"
  634. >
  635. </DialogTemplate>
  636. <span slot="footer" class="dialog-footer">
  637. <el-button @click="btnDialogVisible = false">取 消</el-button>
  638. <el-button type="primary" @click="btnComfirm">确 定</el-button>
  639. </span>
  640. </el-dialog>
  641. <!-- 自定义弹窗 -->
  642. <el-dialog
  643. title="提示"
  644. :visible.sync="btnDialogVisible"
  645. :before-close="handleClose"
  646. >
  647. <DialogTemplate
  648. ref="dialogRef"
  649. :groupKey="groupKey"
  650. :rowobj="rowobj"
  651. :subCount="subCount"
  652. :tableCount="tableCount"
  653. :subTableName="subTableName"
  654. @addList="addListHandler"
  655. >
  656. </DialogTemplate>
  657. <span slot="footer" class="dialog-footer">
  658. <el-button @click="btnDialogVisible = false">取 消</el-button>
  659. <el-button type="primary" @click="btnComfirm">确 定</el-button>
  660. </span>
  661. </el-dialog>
  662. </div>
  663. </template>
  664. <script>
  665. import {
  666. delTableData,
  667. dragTableInfo,
  668. listTable,
  669. unionListTableData,
  670. getInfoBySqlKey,
  671. btnCommonApi,
  672. addTableData,
  673. batchEdit,
  674. getStatisticList,
  675. // getTableList2,
  676. getTableList1,
  677. } from "@/api/tablelist/commonTable";
  678. import { listData } from "@/api/system/tenant/data";
  679. import { getToken } from "@/utils/auth";
  680. import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
  681. import { camelCase, toUnderline } from "@/utils";
  682. import { inputDisableComplete } from "@/utils/other";
  683. import Menu from "@/views/tablelist/commonTable/BtnMenu.vue";
  684. import { checkRole } from "@/utils/permission";
  685. import DialogTemplate from "@/views/dialogTemplate/components/index.vue";
  686. import { queryDropDownBoxData } from "@/api/dragform/form";
  687. import { v4 as uuidv4 } from "uuid";
  688. import { mapState } from "vuex";
  689. export default {
  690. name: "listInfo",
  691. components: { Queryfrom, Menu, DialogTemplate },
  692. dicts: ["sales_order_type"],
  693. data() {
  694. return {
  695. // 审批相关数据
  696. approveType: "", //审批状态
  697. approveNo: "",
  698. approveForm: {
  699. status: "3",
  700. orderType: "",
  701. saleLeader: "", //业务主管
  702. finance: "", //财务部
  703. production: "", //生产部
  704. saleApprover: "", //批准人
  705. },
  706. approveRule: {
  707. orderType: [
  708. {
  709. required: true,
  710. message: "请选择订单类型",
  711. trigger: "change",
  712. },
  713. ],
  714. },
  715. // 新的自定义数据 start
  716. productIds: [], //货品Ids
  717. isEdit: false,
  718. formData: {
  719. //订单表数据
  720. saleNo: "", //合同号
  721. saleCustomNo: "", //客户编号
  722. saleDate: "", //销售单日期
  723. saleOrderEstimatedTime: "", //预计下单时间
  724. saleLeadTime: "", //交货周期
  725. saleAmounts: "", //合计金额 小写
  726. saleAmountInWords: "", //合计金额 大写
  727. salePayType: "", //支付方式
  728. salesman: "", //业务员
  729. saleLeader: "", //业务主管
  730. finance: "", //财务部
  731. production: "", //生产部
  732. saleApprover: "", //批准人
  733. customAddress: "", //客户地址
  734. customCountryType: "", //国家类型
  735. contactPerson: "", //联系人
  736. // 货品明细表数据
  737. productNo: "", //货品号
  738. productName: "", //货品名称
  739. productNumber: "", //销售数量
  740. productWeight: "", //销售重量kg
  741. productUnitPrice: "", //单价
  742. productAmounts: "", //金额
  743. remark: "", //备注
  744. // 工艺表
  745. craftGrid: "", //网格
  746. craftOil: "", //油剂
  747. craftPackage: "", //卷装
  748. craftColorFastness: "", //色牢度
  749. craftOther: "", //其它工艺要求
  750. craftMark: "", //包装/贴唛
  751. shippingMethod: "", //运输方式
  752. },
  753. productionOptions: [],
  754. customerOptions: [],
  755. productionTableData: [
  756. // {
  757. // productNo: "", //货品名称
  758. // productNumber: 2, //销售数量
  759. // productWeight: 1, //销售重量kg
  760. // productUnitPrice: 20, //单价
  761. // productAmounts: 20, //金额
  762. // remark: "", //备注
  763. // },
  764. ],
  765. rules: {},
  766. // end
  767. // 绑定按钮dialog
  768. btnDialogVisible: false,
  769. // 绑定修改dialog
  770. groupKey: "",
  771. // 遮罩层
  772. loading: true,
  773. // 选中数组
  774. ids: [],
  775. // 非单个禁用
  776. single: true,
  777. // 非多个禁用
  778. multiple: true,
  779. // 显示统计
  780. showCount: true,
  781. // 显示搜索条件
  782. showSearch: true,
  783. // 总条数
  784. total: 0,
  785. // 用户表格数据
  786. tableList: [],
  787. // 弹出层标题
  788. title: "",
  789. // 日期范围
  790. dateRange: [],
  791. // 表单参数
  792. form: {},
  793. rules: {},
  794. // cru 弹窗
  795. open: false,
  796. // excel共通导入数据
  797. upload: {
  798. // 是否显示弹出层
  799. open: false,
  800. // 弹出层标题(
  801. title: "",
  802. // 是否禁用上传
  803. isUploading: false,
  804. // 是否更新已经存在的数据
  805. updateSupport: 0,
  806. // 设置上传的请求头部
  807. headers: { Authorization: "Bearer " + getToken() },
  808. // 上传的地址
  809. url: process.env.VUE_APP_BASE_API3 + "common/uploadData",
  810. },
  811. // 排序方式 默认降序
  812. sortOrder: true,
  813. // 共通查询参数接受子组件的参数
  814. queryParams: {
  815. pageNum: 1, // 第几页
  816. pageSize: 10, // 每页大小
  817. orderByColumn: "", // 根据某列排序
  818. isAsc: "", // desc(降序)或 asc(升序)
  819. // 基本查询参数
  820. basicMap: {
  821. tableName: "drag_form",
  822. },
  823. // 当前表字段筛选参数
  824. queryMap: {
  825. // 当前查询基本参数
  826. // ... key : value 当前页面的筛选条件
  827. // 超级查询的唯一值
  828. queryCriteriaValue: "",
  829. },
  830. conditionMap: {
  831. columnName: "status",
  832. columnValue: "2",
  833. },
  834. },
  835. // 列信息
  836. columns: {},
  837. // 当前模版信息
  838. templateInfo: {},
  839. // 查询条件
  840. queryFromWhere: {},
  841. // 当前table唯一标识
  842. tableKey: null,
  843. // 当前表名称
  844. tableName: null,
  845. //存放html代码块
  846. iframeUrl: "",
  847. //存放表单渲染数据
  848. jsonData: {},
  849. // 回显表格数据,
  850. defaultValue: {},
  851. // 统计card
  852. statisticList: [],
  853. // 样式表
  854. styleList: [],
  855. // 字典样式对象
  856. dictStyleObj: {},
  857. // 操作列 按钮数据
  858. excuteBtnArr: [],
  859. // 下拉框动态数据
  860. dynamicData: {},
  861. // 当前点击按钮的数据
  862. currentBtnData: {},
  863. // 修改选中行
  864. rowobj: {},
  865. // 该行的统计信息
  866. subCount: [],
  867. tableCount: [],
  868. // 弹窗新增数据
  869. addLists: [],
  870. subTableName: "",
  871. // 当前点击行的数据
  872. currentRow: {},
  873. };
  874. },
  875. created() {
  876. // 得到当前展示的table的唯一标识
  877. this.tableKey = this.$route.query.tableKey;
  878. console.log(this.user);
  879. },
  880. watch: {},
  881. computed: {
  882. isShowExcuteCol() {
  883. return !this.excuteBtnArr?.every((arr) => arr.children.length == 0);
  884. },
  885. ...mapState({
  886. nickName: (state) => state.user.nickName,
  887. user: (state) => state.user,
  888. }),
  889. },
  890. methods: {
  891. // 审批状态改变回调
  892. approveTypeChange(status) {
  893. this.getList(false, status);
  894. },
  895. // 审批 开始回调
  896. approveHandler(index, row) {
  897. console.log(row);
  898. },
  899. // 审批 确认回调
  900. approveConfirm() {
  901. // console.log(this.dict.type.sales_order_type);
  902. this.$refs["approveFormRef"].validate(async (valid) => {
  903. if (valid) {
  904. let { status, orderType, saleLeader, finance, production } =
  905. this.approveForm;
  906. let baseFormInfo = {
  907. saleLeader,
  908. finance,
  909. production,
  910. };
  911. // baseFormInfo.saleApprover = this.nickName;
  912. let payload = {
  913. basicMap: {
  914. tableName: "sale_order",
  915. },
  916. commMap: {
  917. // status: orderType == "2" ? "3" : "5",
  918. // orderType,
  919. // saleApprover: this.nickName,
  920. },
  921. conditionMap: {
  922. saleNo: this.approveNo,
  923. },
  924. };
  925. if (status == "7") {
  926. // 不通过
  927. payload.commMap = {
  928. status,
  929. saleApprover: this.nickName,
  930. ...baseFormInfo,
  931. };
  932. } else {
  933. //通过
  934. if (orderType == "2") {
  935. //生产
  936. payload.commMap = {
  937. status: "3",
  938. orderType,
  939. saleApprover: this.nickName,
  940. ...baseFormInfo,
  941. };
  942. } else if (orderType == "1") {
  943. //库存
  944. payload.commMap = {
  945. status: "5",
  946. orderType,
  947. saleApprover: this.nickName,
  948. ...baseFormInfo,
  949. };
  950. }
  951. }
  952. let res = await batchEdit(payload);
  953. if (res.code === 200) {
  954. this.$message.success("审批成功");
  955. this.open = false;
  956. this.getList();
  957. } else {
  958. this.$message.error("审批失败");
  959. }
  960. } else {
  961. return false;
  962. }
  963. });
  964. },
  965. // 初始化审批表单数据
  966. initApproveFormData() {
  967. Object.assign(this.approveForm, {
  968. status: "3",
  969. orderType: "",
  970. });
  971. },
  972. // 重置审计表单数据
  973. resetFormData() {
  974. Object.assign(this.formData, {
  975. //订单表数据
  976. saleNo: "", //合同号
  977. saleCustomNo: "", //客户编号
  978. saleDate: "", //销售单日期
  979. saleOrderEstimatedTime: "", //预计下单时间
  980. saleLeadTime: "", //交货周期
  981. saleAmounts: "", //合计金额 小写
  982. saleAmountInWords: "", //合计金额 大写
  983. salePayType: "", //支付方式
  984. salesman: "", //业务员
  985. saleLeader: "", //业务主管
  986. finance: "", //财务部
  987. production: "", //生产部
  988. saleApprover: "", //批准人
  989. customAddress: "", //客户地址
  990. customCountryType: "", //国家类型
  991. contactPerson: "", //联系人
  992. // 货品明细表数据
  993. productNo: "", //货品号
  994. productName: "", //货品名称
  995. productNumber: "", //销售数量
  996. productWeight: "", //销售重量kg
  997. productUnitPrice: "", //单价
  998. productAmounts: "", //金额
  999. remark: "", //备注
  1000. // 工艺表
  1001. craftGrid: "", //网格
  1002. craftOil: "", //油剂
  1003. craftPackage: "", //卷装
  1004. craftColorFastness: "", //色牢度
  1005. craftOther: "", //其它工艺要求
  1006. craftMark: "", //包装/贴唛
  1007. shippingMethod: "", //运输方式
  1008. });
  1009. this.productionTableData = [];
  1010. },
  1011. // 自定义的小计计算方法
  1012. getSummaries(param) {
  1013. const { columns, data } = param;
  1014. console.log(columns, data);
  1015. const sums = [];
  1016. columns.forEach((column, index) => {
  1017. if (index === 0) {
  1018. sums[index] = "小计";
  1019. return;
  1020. }
  1021. const values = data.map((item) => Number(item[column.property]));
  1022. if (index === 2 || index === 4 || index === 5) {
  1023. sums[index] = "";
  1024. } else if (!values.every((value) => isNaN(value))) {
  1025. sums[index] = values.reduce((prev, curr) => {
  1026. const value = Number(curr);
  1027. if (!isNaN(value)) {
  1028. return prev + curr;
  1029. } else {
  1030. return prev;
  1031. }
  1032. }, 0);
  1033. sums[index];
  1034. } else {
  1035. sums[index] = "N/A";
  1036. }
  1037. });
  1038. return sums;
  1039. },
  1040. // 货品表格数据删除回调
  1041. deleteProduct(index) {
  1042. this.productionTableData.splice(index, 1);
  1043. },
  1044. // 货品表格数据新增回调
  1045. addProduct() {
  1046. this.productionTableData.push({
  1047. saleProductNo: uuidv4(),
  1048. productNo: "", //货品编号
  1049. productName: "", //货品名称
  1050. productNumber: "", //销售数量
  1051. productWeight: "", //销售重量kg
  1052. productUnitPrice: "", //单价
  1053. productAmounts: "", //金额
  1054. remark: "", //备注
  1055. });
  1056. },
  1057. // 客户名称改变回调
  1058. customChangeHandler(val) {
  1059. // if (!val) return;
  1060. let customData = this.customerOptions.find(
  1061. (item) => item.customNo == val
  1062. );
  1063. this.formData.customAddress = customData?.customAddress || "无";
  1064. this.formData.customCountryType = customData?.customCountryType || "无";
  1065. this.formData.contactPerson = customData?.contactPerson || "无";
  1066. },
  1067. //审计新增
  1068. async addHandler() {
  1069. this.isEdit = false;
  1070. await this.getDropDownData();
  1071. this.resetFormData();
  1072. this.title = "新增审计单";
  1073. this.open = true;
  1074. },
  1075. // 获取下拉框数据
  1076. async getDropDownData() {
  1077. try {
  1078. let payLoad = [
  1079. {
  1080. basicMap: {
  1081. tableName: "production",
  1082. },
  1083. },
  1084. {
  1085. basicMap: {
  1086. tableName: "customer",
  1087. },
  1088. },
  1089. ];
  1090. let res = await queryDropDownBoxData(payLoad);
  1091. if (res.code == 200) {
  1092. let { production, customer } = res.data.resultMap;
  1093. this.productionOptions = production || [];
  1094. this.customerOptions = customer || [];
  1095. } else {
  1096. throw Error("获取下拉框数据失败");
  1097. }
  1098. } catch (error) {
  1099. console.log(error);
  1100. }
  1101. },
  1102. // 获取row-key
  1103. getRowKey(row) {
  1104. return row[
  1105. camelCase(this.tableName + "_" + this.templateInfo.template?.primaryKey)
  1106. ];
  1107. },
  1108. /** 查询列表 */
  1109. getList(queryParams, orderStatus = "") {
  1110. this.loading = true;
  1111. // 序列化当前查询参数列表
  1112. queryParams && (this.queryParams.queryMap = queryParams.queryMap);
  1113. // 获取当前表单结构信息
  1114. dragTableInfo({ queryMap: { tableKey: this.tableKey } })
  1115. .then((res) => {
  1116. // 得到当前模版信息 --- sql columns queryWhere
  1117. this.templateInfo = res.data.resultMap;
  1118. this.styleList = res.data.resultMap.style?.map((item) => {
  1119. item.styleField = camelCase(
  1120. item.styleField.replace(".", "_") || ""
  1121. );
  1122. return item;
  1123. });
  1124. // 获取操作列的按钮数据
  1125. this.excuteBtnArr = res.data.resultMap.button;
  1126. this.queryParams.orderByColumn =
  1127. res.data.resultMap.querySql.orderByColumn;
  1128. this.sortOrder = JSON.parse(res.data.resultMap.querySql.sortOrder);
  1129. // 根据拖拽时设置当前列表排列顺序
  1130. this.queryParams.isAsc = this.sortOrder ? "DESC" : "ASC";
  1131. this.tableName = this.templateInfo.template.dtTableName;
  1132. // 得到查询条件
  1133. this.queryFromWhere = res.data.resultMap.where;
  1134. // 得到当前列表信息
  1135. this.columns = this.columnsHandler(
  1136. JSON.parse(this.templateInfo.template.dtColumnName)
  1137. );
  1138. })
  1139. .finally((fes) => {
  1140. if (this.templateInfo == {}) return;
  1141. // 调用查询需要携带当前table的唯一标识
  1142. this.queryParams.queryMap.sqlkey = this.templateInfo.template.sqlKey;
  1143. this.queryParams.orderByColumn = camelCase(
  1144. this.queryParams.orderByColumn || ""
  1145. );
  1146. // let getListFun = orderStatus ? getTableList2 : unionListTableData;
  1147. // if(){}
  1148. // 根据sql语句查询当前表数据
  1149. getTableList1(this.queryParams).then(async (res) => {
  1150. this.tableList = [];
  1151. res.rows.forEach((item) => {
  1152. this.tableList.push(item.resultMap);
  1153. });
  1154. // 驼峰转换
  1155. let tempTableList = [];
  1156. tempTableList = this.tableList.map((item) => {
  1157. let kv = {};
  1158. for (let itemKey in item) {
  1159. kv[camelCase(itemKey)] = item[itemKey];
  1160. }
  1161. return kv;
  1162. });
  1163. // this.setDictStyleData().then(() => {
  1164. // this.tableList = this.setFieldStyleData(this.tableList);
  1165. // });
  1166. this.tableList = await this.setFieldStyleData(tempTableList);
  1167. this.total = res.total;
  1168. // this.$nextTick(() => {
  1169. // this.$refs.tableRef?.clearSelection();
  1170. // });
  1171. this.loading = false;
  1172. });
  1173. // 查询统计信息
  1174. getStatisticList({
  1175. queryMap: {
  1176. tableKey: this.templateInfo.template.tableKey,
  1177. queryCriteriaValue: this.queryParams.queryMap.queryCriteriaValue,
  1178. },
  1179. }).then((res) => {
  1180. this.statisticList = res.data;
  1181. });
  1182. });
  1183. },
  1184. // 审计 提交编辑结果按钮回调
  1185. async editConfirm() {
  1186. this.$refs.formDataRef.validate(async (valid) => {
  1187. if (valid) {
  1188. let {
  1189. //订单表数据
  1190. saleCustomNo,
  1191. saleDate,
  1192. saleOrderEstimatedTime,
  1193. saleLeadTime,
  1194. saleAmounts,
  1195. saleAmountInWords,
  1196. salePayType,
  1197. salesman,
  1198. saleLeader,
  1199. finance,
  1200. production,
  1201. saleApprover,
  1202. // 工艺表数据
  1203. craftGrid,
  1204. craftOil,
  1205. craftPackage,
  1206. craftColorFastness,
  1207. craftOther,
  1208. craftMark,
  1209. shippingMethod,
  1210. } = this.formData;
  1211. let saleCraftNo = this.isEdit ? this.formData.saleCraftNo : uuidv4(),
  1212. saleNo = this.isEdit ? this.formData.saleNo : uuidv4();
  1213. let saleProductsNo = this.productionTableData
  1214. .map((item) => item.saleProductNo)
  1215. .join(","); //销售单表sale_products_no字段存货品表的sale_product_no,逗号分割
  1216. let saleValue = {
  1217. status: 1, //新增销售单时 默认为1
  1218. saleNo,
  1219. saleProductsNo,
  1220. saleOrderTechnologyNo: saleCraftNo,
  1221. saleCustomNo,
  1222. saleDate,
  1223. saleOrderEstimatedTime,
  1224. saleLeadTime,
  1225. // saleAmounts, //合计金额 小写
  1226. saleAmountInWords,
  1227. salePayType,
  1228. salesman,
  1229. saleLeader,
  1230. finance,
  1231. production,
  1232. saleApprover,
  1233. };
  1234. let craftValue = {
  1235. saleOrderNo: saleNo,
  1236. saleCraftNo,
  1237. craftGrid,
  1238. craftOil,
  1239. craftPackage,
  1240. craftColorFastness,
  1241. craftOther,
  1242. craftMark,
  1243. shippingMethod,
  1244. };
  1245. let saleData = {
  1246. //订单表新增数据
  1247. basicMap: {
  1248. tableName: "sale_order",
  1249. },
  1250. // addListMap: [saleValue],
  1251. conditionMap: {},
  1252. commMap: {},
  1253. btnParametersMap: {},
  1254. };
  1255. let craftData = {
  1256. //工艺表新增数据
  1257. basicMap: {
  1258. tableName: "sale_craft",
  1259. },
  1260. // addListMap: [craftValue],
  1261. conditionMap: {},
  1262. commMap: {},
  1263. btnParametersMap: {},
  1264. };
  1265. this.productionTableData.forEach((item) => {
  1266. item.saleOrderNo = saleNo;
  1267. });
  1268. let productData = {
  1269. //货品表新增数据
  1270. basicMap: {
  1271. tableName: "sale_products",
  1272. },
  1273. addListMap: [...this.productionTableData],
  1274. conditionMap: {},
  1275. commMap: {},
  1276. btnParametersMap: {},
  1277. };
  1278. if (this.isEdit) {
  1279. //修改
  1280. Object.keys(saleValue).map((k) => {
  1281. saleData.commMap[k] = saleValue[k];
  1282. });
  1283. Object.keys(craftValue).map((k) => {
  1284. craftData.commMap[k] = craftValue[k];
  1285. });
  1286. saleData.conditionMap.saleNo = saleValue.saleNo;
  1287. craftData.conditionMap.saleCraftNo = craftValue.saleCraftNo;
  1288. // for(let i = 0;i<this.)
  1289. let deletPayload = {
  1290. //删除货品数据的接口
  1291. basicMap: {
  1292. tableName: "sale_products",
  1293. },
  1294. conditionMap: {
  1295. saleProductNo: this.productIds,
  1296. },
  1297. };
  1298. let delRes = { code: 200 };
  1299. if (this.productIds.length) {
  1300. delRes = await delTableData(deletPayload); //删除旧数据
  1301. }
  1302. let updateSaleRes = await batchEdit(saleData);
  1303. let updateCraftRes = await batchEdit(craftData);
  1304. let addProductRes = { code: 200 };
  1305. if (productData.addListMap.length) {
  1306. addProductRes = await addTableData(productData);
  1307. }
  1308. console.log(delRes, updateSaleRes, updateCraftRes, addProductRes);
  1309. if (
  1310. delRes?.code === 200 &&
  1311. updateSaleRes?.code === 200 &&
  1312. updateCraftRes?.code === 200 &&
  1313. addProductRes?.code === 200
  1314. ) {
  1315. this.$message.success("修改成功");
  1316. this.open = false;
  1317. this.getList();
  1318. } else {
  1319. this.$message.error("修改失败");
  1320. }
  1321. } else {
  1322. //新增
  1323. saleData.addListMap = [saleValue];
  1324. craftData.addListMap = [craftValue];
  1325. let saleRes = await addTableData(saleData);
  1326. let craftRes = await addTableData(craftData);
  1327. let productRes = await addTableData(productData);
  1328. if (
  1329. saleRes.code === 200 &&
  1330. craftRes.code === 200 &&
  1331. productRes.code === 200
  1332. ) {
  1333. this.$message.success("添加成功");
  1334. this.open = false;
  1335. this.getList();
  1336. } else {
  1337. this.$message.error("添加失败");
  1338. }
  1339. }
  1340. // Object.keys(saleValue).map((k) => {
  1341. // saleData.commMap[k] = saleValue[k];
  1342. // });
  1343. }
  1344. });
  1345. },
  1346. // 审计 编辑回调
  1347. async handleEdit(index, row) {
  1348. console.log(row);
  1349. let { saleOrderSaleNo } = row;
  1350. this.approveNo = saleOrderSaleNo;
  1351. try {
  1352. let payLoad = [
  1353. {
  1354. basicMap: {
  1355. tableName: "sale_order",
  1356. },
  1357. conditionMap: {
  1358. sale_no: [saleOrderSaleNo],
  1359. },
  1360. },
  1361. {
  1362. basicMap: {
  1363. tableName: "sale_products",
  1364. },
  1365. conditionMap: {
  1366. sale_order_no: [saleOrderSaleNo],
  1367. },
  1368. },
  1369. {
  1370. basicMap: {
  1371. tableName: "sale_craft",
  1372. },
  1373. conditionMap: {
  1374. sale_order_no: [saleOrderSaleNo],
  1375. },
  1376. },
  1377. ];
  1378. let res = await queryDropDownBoxData(payLoad);
  1379. if (res.code == 200) {
  1380. this.isEdit = true;
  1381. let { sale_craft, sale_order, sale_products } = res.data.resultMap;
  1382. Object.assign(this.formData, {
  1383. ...sale_craft[0],
  1384. ...sale_order[0],
  1385. });
  1386. let { saleDate, saleOrderEstimatedTime } = sale_order[0];
  1387. saleDate && (this.formData.saleDate = new Date(saleDate));
  1388. saleOrderEstimatedTime &&
  1389. (this.formData.saleOrderEstimatedTime = saleOrderEstimatedTime);
  1390. this.productionTableData = sale_products;
  1391. this.productIds = sale_products.map((item) => item.saleProductNo);
  1392. await this.getDropDownData();
  1393. this.title = "编辑审计单";
  1394. this.open = true;
  1395. }
  1396. } catch (error) {
  1397. console.log(error);
  1398. }
  1399. },
  1400. // 审计 批量删除回调
  1401. async batchDelete() {
  1402. if (!this.ids.length) return;
  1403. try {
  1404. await this.$confirm("是否确认删除选中的数据?", "警告", {
  1405. confirmButtonText: "确定",
  1406. cancelButtonText: "取消",
  1407. type: "warning",
  1408. });
  1409. let orderPayload = {
  1410. basicMap: {
  1411. tableName: "sale_order",
  1412. },
  1413. conditionMap: {
  1414. saleNo: this.ids,
  1415. },
  1416. };
  1417. let productsPayload = {
  1418. basicMap: {
  1419. tableName: "sale_products",
  1420. },
  1421. conditionMap: {
  1422. saleOrderNo: this.ids,
  1423. },
  1424. };
  1425. let craftPayload = {
  1426. basicMap: {
  1427. tableName: "sale_craft",
  1428. },
  1429. conditionMap: {
  1430. saleOrderNo: this.ids,
  1431. },
  1432. };
  1433. let orderRes = await delTableData(orderPayload);
  1434. let productRes = await delTableData(productsPayload);
  1435. let craftRes = await delTableData(craftPayload);
  1436. if (
  1437. orderRes.code == 200 &&
  1438. productRes.code == 200 &&
  1439. craftRes.code == 200
  1440. ) {
  1441. this.$message.success("删除成功");
  1442. this.getList();
  1443. } else {
  1444. this.$message.error("删除失败");
  1445. throw Error("删除失败");
  1446. }
  1447. } catch (error) {
  1448. console.log(error);
  1449. }
  1450. },
  1451. isUpperCase(char) {
  1452. return char === char.toUpperCase();
  1453. },
  1454. // 下划线命名转驼峰命名
  1455. toUnderScoreCase(str) {
  1456. if (str === null) {
  1457. return null;
  1458. }
  1459. let sb = "";
  1460. // 前置字符是否大写
  1461. let preCharIsUpperCase = true;
  1462. // 当前字符是否大写
  1463. let curreCharIsUpperCase = true;
  1464. // 下一字符是否大写
  1465. let nexteCharIsUpperCase = true;
  1466. for (let i = 0; i < str.length; i++) {
  1467. let c = str.charAt(i);
  1468. if (i > 0) {
  1469. preCharIsUpperCase = isUpperCase(str.charAt(i - 1));
  1470. } else {
  1471. preCharIsUpperCase = false;
  1472. }
  1473. curreCharIsUpperCase = isUpperCase(c);
  1474. if (i < str.length - 1) {
  1475. nexteCharIsUpperCase = isUpperCase(str.charAt(i + 1));
  1476. }
  1477. if (
  1478. preCharIsUpperCase &&
  1479. curreCharIsUpperCase &&
  1480. !nexteCharIsUpperCase
  1481. ) {
  1482. sb += SEPARATOR;
  1483. } else if (i !== 0 && !preCharIsUpperCase && curreCharIsUpperCase) {
  1484. sb += SEPARATOR;
  1485. }
  1486. sb += c.toLowerCase();
  1487. }
  1488. return sb;
  1489. },
  1490. // 处理列表信息
  1491. columnsHandler(columns) {
  1492. let resArr = [];
  1493. columns.forEach((item) => {
  1494. for (const key in item) {
  1495. let tempObj = {};
  1496. tempObj.key = camelCase(key);
  1497. tempObj.value = item[key];
  1498. resArr.push(tempObj);
  1499. }
  1500. });
  1501. return resArr;
  1502. },
  1503. // 取消按钮
  1504. cancel() {
  1505. this.open = false;
  1506. // this.reset();
  1507. },
  1508. // 分页查询
  1509. pageList(row) {
  1510. // 调用子组件-》携带子组件参数请求后台
  1511. this.$refs.mychild.pageList(
  1512. row == undefined
  1513. ? {
  1514. limit: this.queryParams.pageSize,
  1515. page: this.queryParams.pageNum,
  1516. }
  1517. : row
  1518. );
  1519. },
  1520. // 多选框选中数据
  1521. handleSelectionChange(selection) {
  1522. // this.ids = selection.map(
  1523. // (item) =>
  1524. // item[
  1525. // camelCase(
  1526. // this.tableName + "_" + this.templateInfo.template?.primaryKey
  1527. // )
  1528. // ]
  1529. // );
  1530. this.ids = selection.map((item) => item.saleOrderSaleNo);
  1531. this.single = selection.length != 1;
  1532. this.multiple = !selection.length;
  1533. },
  1534. // 更多操作触发
  1535. handleCommand(command, row) {
  1536. switch (command) {
  1537. case "handleResetPwd":
  1538. this.handleResetPwd(row);
  1539. break;
  1540. case "handleAuthRole":
  1541. this.handleAuthRole(row);
  1542. break;
  1543. default:
  1544. break;
  1545. }
  1546. },
  1547. /** 新增按钮操作 */
  1548. handleAdd(row) {
  1549. // this.reset();
  1550. this.defaultValue = {};
  1551. getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1552. if (!data || !data.dfVueTemplate) {
  1553. this.jsonData = false;
  1554. this.$message.error("当前表格未绑定表单!");
  1555. return;
  1556. }
  1557. if (data.dfFormSql) {
  1558. let dynamicData = JSON.parse(data.dfFormSql);
  1559. Object.assign(this.dynamicData, dynamicData);
  1560. }
  1561. this.jsonData = JSON.parse(data.dfVueTemplate);
  1562. this.open = true;
  1563. this.title = "添加信息";
  1564. this.form.password = this.initPassword;
  1565. this.$nextTick(() => {
  1566. this.$refs.addFromRef.reset();
  1567. inputDisableComplete();
  1568. });
  1569. });
  1570. },
  1571. longestCommonSubstring(strs) {
  1572. if (!strs || strs.includes("")) return "";
  1573. let str1_Length = strs[0].length;
  1574. let str_Nums = strs.length;
  1575. let flag = 0;
  1576. for (let i = 0; i < str1_Length && flag == 0; i++) {
  1577. let char = strs[0][i];
  1578. for (var j = 1; j < str_Nums; j++) {
  1579. if (char !== strs[j][i] || i == strs[j].length) {
  1580. return strs[1].substring(0, i);
  1581. }
  1582. }
  1583. }
  1584. return strs[0];
  1585. },
  1586. // 绑定dialog对话框关闭
  1587. handleClose() {
  1588. this.btnDialogVisible = false;
  1589. },
  1590. getLastUppercaseWord(text) {
  1591. const pattern = /\b[A-Z][a-z]*\b/g;
  1592. const matches = [...text.matchAll(pattern)];
  1593. if (matches.length > 0) {
  1594. const lastMatch = matches[matches.length - 1][0];
  1595. return lastMatch;
  1596. } else {
  1597. return null;
  1598. }
  1599. },
  1600. /** 修改按钮操作 */
  1601. async handleUpdate(row, btnData) {
  1602. let nameTable = this.templateInfo.template.dtTableName;
  1603. this.rowobj = {};
  1604. let obj = {};
  1605. for (let key in row) {
  1606. let modifiedTable = key
  1607. .replace(/[A-Z]/g, (match) => `_${match}`)
  1608. .toLowerCase();
  1609. this.rowobj[modifiedTable] = row[key];
  1610. let str = modifiedTable.substring(nameTable.length + 1);
  1611. obj[str] = row[key];
  1612. }
  1613. // getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1614. // if (!data || !data.dfVueTemplate) {
  1615. // this.$message.error("当前表格未绑定表单!");
  1616. // return;
  1617. // }});
  1618. // 新的修改请求
  1619. try {
  1620. let payLoad = {
  1621. basicMap: {
  1622. btnType: this.currentBtnData.btnType,
  1623. btnKey: this.currentBtnData.btnKey,
  1624. visible: "false",
  1625. sqlKey: this.templateInfo.template.sqlKey,
  1626. tableName: this.tableName,
  1627. },
  1628. conditionMap: {},
  1629. };
  1630. let primary = camelCase(
  1631. this.tableName + "_" + this.templateInfo.template?.primaryKey
  1632. );
  1633. payLoad.conditionMap[this.templateInfo.template?.primaryKey] =
  1634. row[primary];
  1635. let res = await btnCommonApi(payLoad);
  1636. // 判断是否绑定dialog弹窗
  1637. if (!this.currentBtnData.btnTableFormGroupKey) {
  1638. if (!res.data || !res.data.template) {
  1639. this.$message.error("当前按钮未绑定表单!");
  1640. return;
  1641. }
  1642. res.data.template.dfFormSql &&
  1643. (this.dynamicData = JSON.parse(res.data.template.dfFormSql));
  1644. this.addRealFieldName(res.data.result.resultMap);
  1645. let resultMap = res.data.result.resultMap;
  1646. Object.assign(this.defaultValue, resultMap);
  1647. this.jsonData = JSON.parse(res.data.template.dfVueTemplate);
  1648. this.open = true;
  1649. this.title = "修改信息";
  1650. this.form.password = this.initPassword;
  1651. this.$nextTick(() => {
  1652. this.$refs.addFromRef.setData(res.data.result.resultMap);
  1653. });
  1654. } else {
  1655. this.subTableName = res.data.result.dragTables[1].dtTableName;
  1656. this.btnDialogVisible = true;
  1657. this.groupKey = this.currentBtnData.btnTableFormGroupKey;
  1658. this.$nextTick(() => {
  1659. let refChild = this.$refs.dialogRef;
  1660. refChild.getLists(this.groupKey);
  1661. });
  1662. let tablesubKey = res.data.result.dragTables[1].tableKey;
  1663. // 查询统计信息
  1664. getStatisticList({
  1665. queryMap: {
  1666. tableKey: tablesubKey,
  1667. },
  1668. }).then((res) => {
  1669. this.subCount = res.data;
  1670. });
  1671. let prmKey = this.templateInfo.template.primaryKey;
  1672. let pkey = prmKey.replace(/_([a-z])/g, (match, p1) =>
  1673. p1.toUpperCase()
  1674. );
  1675. let data = {
  1676. queryMap: {
  1677. tableKey: res.data.result.dragTables[2].tableKey,
  1678. },
  1679. };
  1680. let key =
  1681. "#{" +
  1682. this.templateInfo.template.dtTableName +
  1683. "." +
  1684. this.templateInfo.template.primaryKey;
  1685. data.queryMap[key] =
  1686. "'" + obj[this.templateInfo.template.primaryKey] + "'";
  1687. getStatisticList(data).then((res) => {
  1688. this.tableCount = res.data;
  1689. });
  1690. }
  1691. // let fieldList = Object.keys(resultMap);
  1692. // let tableName = this.longestCommonSubstring(fieldList);
  1693. // fieldList.forEach((field) => {
  1694. // let realField = field.replace(tableName, "");
  1695. // realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  1696. // resultMap[realField] = resultMap[field];
  1697. // });
  1698. } catch (error) {
  1699. this.$message.error("网络异常,请稍后再试");
  1700. console.log(error);
  1701. }
  1702. return;
  1703. // getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1704. // if (!data || !data.dfVueTemplate) {
  1705. // this.$message.error("当前表格未绑定表单!");
  1706. // return;
  1707. // }
  1708. // // let fieldList = Object.keys(row);
  1709. // // let tableName = this.longestCommonSubstring(fieldList);
  1710. // // fieldList.forEach((field) => {
  1711. // // let realField = field.replace(tableName, "");
  1712. // // realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  1713. // // row[realField] = row[field];
  1714. // // });
  1715. // this.addRealFieldName(row);
  1716. // Object.assign(this.defaultValue, row);
  1717. // this.jsonData = JSON.parse(data.dfVueTemplate);
  1718. // this.open = true;
  1719. // this.title = "修改信息";
  1720. // this.form.password = this.initPassword;
  1721. // this.$nextTick(() => {
  1722. // this.$refs.addFromRef.setData(row);
  1723. // });
  1724. // });
  1725. // return;
  1726. this.reset();
  1727. const userId = row.userId || this.ids;
  1728. getUser(userId).then((response) => {
  1729. this.form = response.data;
  1730. this.postOptions = response.posts;
  1731. this.roleOptions = response.roles;
  1732. this.$set(this.form, "postIds", response.postIds);
  1733. this.$set(this.form, "roleIds", response.roleIds);
  1734. this.open = true;
  1735. this.title = "修改当前信息";
  1736. this.form.password = "";
  1737. });
  1738. },
  1739. // 添加真正的字段名
  1740. addRealFieldName(row) {
  1741. let fieldList = Object.keys(row);
  1742. // let tableName = this.longestCommonSubstring(fieldList);
  1743. let tableName = camelCase(this.tableName);
  1744. fieldList.forEach((field) => {
  1745. let realField = field.replace(tableName, "");
  1746. realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  1747. row[realField] = row[field];
  1748. });
  1749. },
  1750. /** 提交按钮 */
  1751. submitForm: function () {
  1752. this.$refs["form"].validate((valid) => {
  1753. if (valid) {
  1754. if (this.form.userId != undefined) {
  1755. updateUser(this.form).then((response) => {
  1756. this.$modal.msgSuccess("修改成功");
  1757. this.open = false;
  1758. this.getList();
  1759. });
  1760. } else {
  1761. addUser(this.form).then((response) => {
  1762. this.$modal.msgSuccess("新增成功");
  1763. this.open = false;
  1764. this.getList();
  1765. });
  1766. }
  1767. }
  1768. });
  1769. },
  1770. /** 删除按钮操作
  1771. *
  1772. * 删除提示信息语句(标识)
  1773. * */
  1774. handleDelete(row, btnData) {
  1775. let delIds = this.ids;
  1776. let primary = camelCase(this.templateInfo.template?.primaryKey);
  1777. // let realyKey=
  1778. this.addRealFieldName(row);
  1779. if (row[primary] != undefined && row[primary] != null) {
  1780. delIds = [];
  1781. delIds.push(row[primary]);
  1782. }
  1783. let data = {
  1784. basicMap: {
  1785. btnType: btnData.btnType,
  1786. btnKey: btnData.btnKey,
  1787. tableName: this.tableName,
  1788. },
  1789. conditionMap: {
  1790. // id: delIds,
  1791. },
  1792. btnParametersMap: {},
  1793. };
  1794. if (this.currentBtnData.btnParams) {
  1795. let btnParams =
  1796. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  1797. let conditionData =
  1798. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  1799. conditionData.forEach((item) => {
  1800. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  1801. ? item.fieldValue
  1802. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  1803. });
  1804. btnParams.forEach((item) => {
  1805. data.btnParametersMap[item.fieldName.split(".")[1]] = item.fieldValue
  1806. ? item.fieldValue
  1807. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  1808. });
  1809. }
  1810. // data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  1811. this.$modal
  1812. .confirm('是否确认删除"' + delIds + '"的数据项?')
  1813. .then(function () {
  1814. // return delTableData(data);
  1815. return btnCommonApi(data);
  1816. })
  1817. .then(() => {
  1818. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  1819. this.$refs.mychild.pageList();
  1820. this.$modal.msgSuccess("删除成功");
  1821. })
  1822. .catch(() => {});
  1823. },
  1824. // 批量删除接口
  1825. handleBatchDelete() {
  1826. let delIds = this.ids;
  1827. let primary = camelCase(this.templateInfo.template?.primaryKey);
  1828. // if (row && row[primary] != undefined && row[primary] != null) {
  1829. // delIds = [];
  1830. // delIds.push(row[primary]);
  1831. // }
  1832. let data = {
  1833. basicMap: {
  1834. tableName: this.tableName,
  1835. },
  1836. conditionMap: {
  1837. // id: delIds,
  1838. },
  1839. };
  1840. // if (this.currentBtnData.btnParams) {
  1841. // let btnParams = JSON.parse(this.currentBtnData.btnParams);
  1842. // btnParams.forEach((item) => {
  1843. // data.btnParametersMap[
  1844. // this.formatField(item.fieldName, camelCase(this.tableName))
  1845. // ] = item.fieldValue
  1846. // ? item.fieldValue
  1847. // : this.currentRow[item.fieldName];
  1848. // });
  1849. // }
  1850. data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  1851. this.$modal
  1852. .confirm('是否确认删除"' + delIds + '"的数据项?')
  1853. .then(function () {
  1854. return delTableData(data);
  1855. // return btnCommonApi(data);
  1856. })
  1857. .then(() => {
  1858. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  1859. this.$refs.mychild.pageList();
  1860. this.$modal.msgSuccess("删除成功");
  1861. })
  1862. .catch(() => {});
  1863. },
  1864. /** 导出按钮操作 */
  1865. handleExport() {
  1866. let primary = camelCase(this.templateInfo.template?.primaryKey);
  1867. let realyKey = camelCase(this.tableName + "_" + primary);
  1868. if (this.ids.length > 0) {
  1869. this.queryParams["execlMap"] = [];
  1870. this.ids.forEach((item) => {
  1871. this.queryParams.execlMap.push(
  1872. this.tableList.find((ttem) => {
  1873. return ttem[realyKey] === item;
  1874. })
  1875. );
  1876. });
  1877. } else {
  1878. this.$message.warning("请至少勾选一条导出数据");
  1879. return;
  1880. }
  1881. this.queryParams.execlMap = JSON.stringify(this.queryParams.execlMap);
  1882. this.download(
  1883. process.env.VUE_APP_BASE_API3 + "common/export",
  1884. {
  1885. ...this.queryParams,
  1886. },
  1887. `文件名称_${new Date().getTime()}.xlsx`
  1888. );
  1889. },
  1890. /** 导入按钮操作 */
  1891. handleImport() {
  1892. this.upload.title = "当前导入";
  1893. this.upload.open = true;
  1894. },
  1895. /** 下载模板操作 */
  1896. importTemplate() {
  1897. this.download(
  1898. process.env.VUE_APP_BASE_API3 +
  1899. `common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.templateInfo.template.sqlKey}`,
  1900. {},
  1901. `下载模版名称${new Date().getTime()}.xlsx`
  1902. );
  1903. },
  1904. // 文件上传中处理
  1905. handleFileUploadProgress(event, file, fileList) {
  1906. this.upload.isUploading = true;
  1907. },
  1908. // 文件上传成功处理
  1909. handleFileSuccess(response, file, fileList) {
  1910. this.upload.open = false;
  1911. this.upload.isUploading = false;
  1912. this.$refs.upload.clearFiles();
  1913. this.$alert(
  1914. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  1915. response.msg +
  1916. "</div>",
  1917. "导入结果",
  1918. { dangerouslyUseHTMLString: true }
  1919. );
  1920. this.$refs.mychild.pageList({
  1921. limit: this.queryParams.pageSize,
  1922. page: this.queryParams.pageNum,
  1923. });
  1924. },
  1925. //重点在这里
  1926. handleChange(file, fileList) {
  1927. file.name = this.tableName + "." + file.name.split(".")[1];
  1928. fileList.forEach((item) => {
  1929. item.name = this.tableName + "." + file.name.split(".")[1];
  1930. });
  1931. let newFile = new File(
  1932. [file],
  1933. this.tableName + "." + file.name.split(".")[1]
  1934. ); //创建出来也是不可编辑的file对象
  1935. },
  1936. // 提交上传文件
  1937. submitFileForm() {
  1938. this.$refs.upload.submit();
  1939. },
  1940. // 弹窗新增的数
  1941. addListHandler(val) {
  1942. this.addLists.push(...val);
  1943. },
  1944. // 绑定弹窗Dialog确定按钮
  1945. btnComfirm() {
  1946. // let data = {
  1947. // addListMap:[],
  1948. // basicMap:{
  1949. // btnType: 10,
  1950. // tableName: this.subTableName,
  1951. // visible: true,
  1952. // },
  1953. // commMap: {},
  1954. // conditionMap: {},
  1955. // }
  1956. // // data.addListMap =
  1957. // btnCommonApi(data).then(res => {
  1958. // console.log('弹窗确定', res);
  1959. // })
  1960. },
  1961. // 去掉表名 开头字母小写
  1962. formatField(field = "", tableName) {
  1963. let temp = field.replace(tableName, "");
  1964. return toUnderline(temp[0].toLowerCase() + temp.slice(1));
  1965. },
  1966. //提交编辑结果按钮回调
  1967. async editConfirmHandler() {
  1968. if (this.$refs.addFromRef) {
  1969. this.$refs.addFromRef
  1970. .getData()
  1971. .then(async (values) => {
  1972. let data = {
  1973. basicMap: {
  1974. tableName: this.tableName,
  1975. // btnKey: btnData.btnKey,
  1976. btnKey: this.currentBtnData.btnKey,
  1977. },
  1978. addListMap: [values],
  1979. conditionMap: {},
  1980. commMap: {},
  1981. btnParametersMap: {},
  1982. };
  1983. if (this.currentBtnData.btnParams) {
  1984. let btnParams =
  1985. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData ||
  1986. [];
  1987. let conditionData =
  1988. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  1989. // let
  1990. btnParams.forEach((item) => {
  1991. data.btnParametersMap[item.fieldName.split(".")[1]] =
  1992. item.fieldValue
  1993. ? item.fieldValue
  1994. : this.currentRow[
  1995. camelCase(item.fieldName.replace(".", "_"))
  1996. ];
  1997. });
  1998. conditionData.forEach((item) => {
  1999. data.conditionMap[item.fieldName.split(".")[1]] =
  2000. item.fieldValue
  2001. ? item.fieldValue
  2002. : this.currentRow[
  2003. camelCase(item.fieldName.replace(".", "_"))
  2004. ];
  2005. });
  2006. }
  2007. if (Object.keys(this.defaultValue).length) {
  2008. // data.conditionMap[this.templateInfo.template?.primaryKey] =
  2009. // this.defaultValue[this.templateInfo.template?.primaryKey];
  2010. Object.keys(values).map((k) => {
  2011. data.commMap[k] = values[k];
  2012. });
  2013. data.basicMap.btnType = this.currentBtnData.btnType;
  2014. data.basicMap.visible = true;
  2015. } else {
  2016. data.basicMap.btnType = "INSERT";
  2017. data.basicMap.visible = true;
  2018. }
  2019. try {
  2020. let res = await btnCommonApi(data);
  2021. if (res.code == 200) {
  2022. this.$message.success("操作成功");
  2023. } else {
  2024. this.$message.error("网络异常,请稍后再试");
  2025. }
  2026. } catch (error) {
  2027. console.log(error);
  2028. this.$message.error("网络异常,请稍后再试");
  2029. }
  2030. this.getList();
  2031. this.defaultValue = {};
  2032. this.open = false;
  2033. })
  2034. .catch((res) => {
  2035. console.log(res);
  2036. this.$modal.msgError("表单校验失败,请规范填写数据");
  2037. });
  2038. } else {
  2039. // 没有绑定表单
  2040. let data = {
  2041. basicMap: {
  2042. tableName: this.tableName,
  2043. // btnKey: btnData.btnKey,
  2044. btnKey: this.currentBtnData.btnKey,
  2045. btnType: this.currentBtnData.btnType,
  2046. visible: true,
  2047. },
  2048. addListMap: [],
  2049. conditionMap: {},
  2050. commMap: {},
  2051. btnParametersMap: {},
  2052. };
  2053. if (this.currentBtnData.btnParams) {
  2054. let btnParams =
  2055. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  2056. let conditionData =
  2057. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2058. conditionData.forEach((item) => {
  2059. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  2060. ? item.fieldValue
  2061. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2062. });
  2063. btnParams.forEach((item) => {
  2064. data.btnParametersMap[item.fieldName.split(".")[1]] =
  2065. item.fieldValue
  2066. ? item.fieldValue
  2067. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2068. });
  2069. }
  2070. // data.basicMap.btnType = this.currentBtnData.btnType;
  2071. // data.basicMap.visible = true;
  2072. try {
  2073. let res = await btnCommonApi(data);
  2074. if (res.code == 200) {
  2075. this.$message.success("操作成功");
  2076. } else {
  2077. this.$message.error("网络异常,请稍后再试");
  2078. }
  2079. } catch (error) {
  2080. console.log(error);
  2081. this.$message.error("网络异常,请稍后再试");
  2082. }
  2083. this.getList();
  2084. this.defaultValue = {};
  2085. this.open = false;
  2086. }
  2087. },
  2088. // 使用提交数据类型的按钮获取数据
  2089. tempSubBtn(getData) {
  2090. getData()
  2091. .then((values) => {
  2092. console.log("验证通过", values);
  2093. })
  2094. .catch(() => {
  2095. console.log("验证未通过,获取失败");
  2096. });
  2097. },
  2098. // 判断是否生效行样式
  2099. cellStyle({ row, column, rowIndex, columnIndex }) {
  2100. let rowStyleList = this.styleList.filter((item) => item.styleType == 0);
  2101. if (!rowStyleList.length) return "";
  2102. let mainTableName = this.templateInfo.querySql.tableAlias; //主表名
  2103. for (let i = 0; i < rowStyleList.length; i++) {
  2104. let item = rowStyleList[i];
  2105. let judgeRes = this.determineCondition(item.styleCondtion, row);
  2106. if (judgeRes) {
  2107. let styleCode = JSON.parse(item.styleCode);
  2108. return `background-color:${styleCode.rowBgColor};`;
  2109. }
  2110. }
  2111. },
  2112. // 获取生效条件组结果
  2113. determineCondition(conditionStr, row) {
  2114. let conditionList = JSON.parse(conditionStr);
  2115. if (!conditionList.length) return false;
  2116. return conditionList.every((item) => this.judgeOneCondition(item, row));
  2117. },
  2118. // 获取单个判断条件结果
  2119. judgeOneCondition(item, row) {
  2120. let fullField = camelCase(item.tableName + "_" + item.fieldName);
  2121. switch (item.condition) {
  2122. case 1:
  2123. return row[fullField] > item.flagValue;
  2124. case 2:
  2125. return row[fullField] < item.flagValue;
  2126. case 3:
  2127. return row[fullField] == item.flagValue;
  2128. case 4:
  2129. return row[fullField] >= item.flagValue;
  2130. case 5:
  2131. return row[fullField] <= item.flagValue;
  2132. default:
  2133. return true; //默认为true
  2134. }
  2135. },
  2136. // 设置表格字段样式
  2137. async setFieldStyleData(tableList) {
  2138. console.log(JSON.parse(JSON.stringify(tableList)));
  2139. let fieldConditionList = this.styleList.filter(
  2140. (item) => item.styleType == 1 || item.styleType == 2
  2141. );
  2142. if (!fieldConditionList.length) return tableList;
  2143. let res = await this.setDictStyleData();
  2144. this.dictStyleObj = res.reduce((pre, item) => {
  2145. return {
  2146. ...pre,
  2147. ...item,
  2148. };
  2149. }, {});
  2150. // console.log("this.dictStyleObj", this.dictStyleObj);
  2151. tableList.forEach((row) => {
  2152. // if (!row.styleFieldObj) row.styleFieldObj = {};
  2153. for (let i = 0; i < fieldConditionList.length; i++) {
  2154. let item = fieldConditionList[i];
  2155. if (item.styleType == 1) {
  2156. //字段样式
  2157. let judgeRes = this.determineCondition(item.styleCondtion, row);
  2158. if (judgeRes) {
  2159. let styleCode = JSON.parse(item.styleCode);
  2160. if (!row.styleFieldObj) row.styleFieldObj = {};
  2161. row.styleFieldObj[item.styleField] = {
  2162. styleType: item.styleType,
  2163. fieldStyleType: styleCode.fieldStyleType,
  2164. fontColor: styleCode.fontColor,
  2165. isTagFullBg: styleCode.isTagFullBg,
  2166. tagType: styleCode.tagType,
  2167. };
  2168. // row.styleField = item.styleField; //样式生效字段
  2169. // row.styleType = item.styleType; //0:行样式 1:字段样式 2:字典样式
  2170. // row.fieldStyleType = styleCode.fieldStyleType; //0:文本 1:标签
  2171. // row.fontColor = styleCode.fontColor;
  2172. // row.isTagFullBg = styleCode.isTagFullBg; //true/false
  2173. // row.tagType = styleCode.tagType; //string
  2174. }
  2175. } else {
  2176. //字典样式
  2177. let dicStyle = this.dictStyleObj[item.styleField]?.find((dict) => {
  2178. return dict.dictValue == row[item.styleField];
  2179. });
  2180. if (dicStyle) {
  2181. if (!row.styleFieldObj) row.styleFieldObj = {};
  2182. row.styleFieldObj[item.styleField] = dicStyle; //设置该字段应该显示的字典样式
  2183. row.styleFieldObj[item.styleField].styleType = 2;
  2184. }
  2185. }
  2186. }
  2187. });
  2188. return tableList;
  2189. },
  2190. //设置表格字典相关数据
  2191. setDictStyleData() {
  2192. let fieldConditionList = this.styleList.filter(
  2193. (item) => item.styleType == 2
  2194. );
  2195. if (!fieldConditionList.length) return;
  2196. let PromiseList = fieldConditionList.map((item) => {
  2197. return new Promise((resolve, reject) => {
  2198. let temp = {};
  2199. try {
  2200. listData({
  2201. isEnablePaging: false,
  2202. dictType: item.styleCondtion,
  2203. }).then((res) => {
  2204. temp[item.styleField] = res.rows;
  2205. resolve(temp);
  2206. });
  2207. } catch (error) {
  2208. reject(error);
  2209. }
  2210. });
  2211. });
  2212. return Promise.all(PromiseList);
  2213. },
  2214. // 内链页面跳转
  2215. routerHandler(btnData, type) {
  2216. let { url, commonFieldData } = JSON.parse(btnData.btnParams);
  2217. let tempArr = [];
  2218. if (commonFieldData) {
  2219. let queryArr = JSON.parse(commonFieldData);
  2220. tempArr = queryArr.map((item) => {
  2221. let key = this.formatField(item.fieldName, camelCase(this.tableName));
  2222. let value = item.fieldValue
  2223. ? item.fieldValue
  2224. : this.currentRow[item.fieldName];
  2225. return key + "=" + value;
  2226. });
  2227. }
  2228. if (tempArr.length) {
  2229. url += "?" + tempArr.join("&");
  2230. }
  2231. // let link = btnData.btnParams;
  2232. if (type == "INNERLINK") {
  2233. this.$router.push(url);
  2234. } else {
  2235. window.open("http://" + url, "_blank");
  2236. }
  2237. },
  2238. // 操作列回调
  2239. excuteHandler(btnData, row) {
  2240. console.log("btnData", btnData, row);
  2241. let { btnType, btnParams, btnFormType } = btnData;
  2242. this.currentBtnData = btnData;
  2243. this.currentRow = JSON.parse(JSON.stringify(row));
  2244. // 无表单
  2245. if (btnFormType == "noNeed") {
  2246. this.noNeedHandler(btnData, row);
  2247. return;
  2248. }
  2249. switch (btnType) {
  2250. case "INNERLINK":
  2251. this.routerHandler(btnData, btnType);
  2252. break;
  2253. case "OUTLINK":
  2254. this.routerHandler(btnData, btnType);
  2255. break;
  2256. case "UPDATE":
  2257. this.handleUpdate(row, btnData);
  2258. break;
  2259. case "EXECUTE":
  2260. this.handleUpdate(row, btnData);
  2261. break;
  2262. case "INITIATED":
  2263. this.handleUpdate(row, btnData);
  2264. break;
  2265. case "DELETE":
  2266. this.handleDelete(row, btnData);
  2267. break;
  2268. default:
  2269. break;
  2270. }
  2271. },
  2272. noNeedHandler(btnData, row) {
  2273. this.$modal
  2274. .confirm("是否确认执行该操作?")
  2275. .then(async () => {
  2276. // 获取默认参数
  2277. let data = {
  2278. basicMap: {
  2279. tableName: this.tableName,
  2280. // btnKey: btnData.btnKey,
  2281. btnKey: this.currentBtnData.btnKey,
  2282. },
  2283. conditionMap: {},
  2284. commMap: {},
  2285. btnParametersMap: {},
  2286. };
  2287. console.log(this.currentBtnData, this.currentRow);
  2288. if (this.currentBtnData.btnParams) {
  2289. let conditionData =
  2290. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2291. // let
  2292. let commonData =
  2293. JSON.parse(this.currentBtnData.btnParams).commonFieldData || [];
  2294. conditionData.forEach((item) => {
  2295. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  2296. ? item.fieldValue
  2297. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2298. });
  2299. commonData.forEach((item) => {
  2300. data.btnParametersMap[item.fieldName.split(".")[1]] =
  2301. item.fieldValue
  2302. ? item.fieldValue
  2303. : this.currentRow[
  2304. camelCase(item.fieldName.replace(".", "_"))
  2305. ];
  2306. });
  2307. }
  2308. data.basicMap.btnType = this.currentBtnData.btnType;
  2309. data.basicMap.visible = true;
  2310. try {
  2311. let res = await btnCommonApi(data);
  2312. if (res.code == 200) {
  2313. this.$message.success(res.msg);
  2314. } else {
  2315. this.$message.error("网络异常,请稍后再试");
  2316. }
  2317. } catch (error) {
  2318. console.log(error);
  2319. this.$message.error("网络异常,请稍后再试");
  2320. }
  2321. })
  2322. .then(() => {
  2323. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  2324. this.$refs.mychild.pageList();
  2325. // this.$modal.msgSuccess("操作成功");
  2326. })
  2327. .catch(() => {});
  2328. },
  2329. // k-form-build表单变化回调
  2330. formChangeHandler(value, label) {
  2331. // console.log(value, label);
  2332. },
  2333. },
  2334. };
  2335. </script>
  2336. <style scoped lang="scss">
  2337. ::v-deep .el-dialog:not(.is-fullscreen) {
  2338. min-width: 610px !important;
  2339. }
  2340. </style>