financeApprove.vue 76 KB

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