13f6d3621ee4140fe0e7e7dc159387a3841bd74c.svn-base 108 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410
  1. <template>
  2. <div class="app-container">
  3. <!-- 配方模板表 -->
  4. <div ref="template" class="template">
  5. <div class="recipeTemplate">
  6. <p>配方模板表</p>
  7. </div>
  8. <div class="operation">
  9. <el-button class="success" @click="handleCreate">新增</el-button>
  10. <el-button class="danger" @click="handleDelete">删除</el-button>
  11. <el-button class="warning" @click="handleCopy">复制</el-button>
  12. <el-button class="success" @click="handleRecipeRecord">配方记录</el-button>
  13. <el-button class="success" @click="handleHistory">生成历史</el-button>
  14. <el-upload style="float: right;margin-right: 75px;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  15. <el-button class="import" style="float: right;">导入</el-button>
  16. </el-upload>
  17. <el-dropdown style="float: right;margin-right: 10px;">
  18. <el-button class="export">导出</el-button>
  19. <el-dropdown-menu slot="dropdown">
  20. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  21. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  22. </el-dropdown-menu>
  23. </el-dropdown>
  24. <el-button class="import" style="float: right;margin-right: 10px;" @click="handleHistoryRecord">历史记录</el-button>
  25. </div>
  26. <div class="search">
  27. <el-select v-model="table.getdataListParm.parammaps.ccname" filterable placeholder="牲畜类别" class="filter-item" clearable>
  28. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  29. </el-select>
  30. <el-select v-model="table.getdataListParm.parammaps.fttype" filterable placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  31. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  32. </el-select>
  33. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  34. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  35. </el-select>
  36. <div ref="selectInput" class="filter-item selectInput">
  37. <el-input type="text" placeholder="请点击选择搜索条件" class="Input" />
  38. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  39. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  40. <ul v-if="arrowUp" class="selectUl">
  41. <li><a>配方名称</a><el-input v-model="table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  42. <li><a>备注</a><el-input v-model="table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  43. <li><a>来源</a><el-input v-model="table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  44. <li>
  45. <div style="float: right;">
  46. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  47. <el-button class="miniPrimary" @click="handleSearch">搜索</el-button>
  48. </div>
  49. </li>
  50. </ul>
  51. </div>
  52. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  53. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  54. </div>
  55. <div class="table">
  56. <el-table
  57. :key="table.tableKey"
  58. v-loading="table.listLoading"
  59. element-loading-text="给我一点时间"
  60. :data="table.list"
  61. border
  62. fit
  63. highlight-current-row
  64. style="width: 98%;"
  65. :row-style="rowStyle"
  66. :cell-style="cellStyle"
  67. class="elTable table-fixed"
  68. @row-click="tableRowClick"
  69. @selection-change="handleSelectionChange"
  70. >
  71. <el-table-column type="selection" align="center" width="50" />
  72. <el-table-column label="序号" align="center" type="index" width="50px">
  73. <template slot-scope="scope">
  74. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="配方名称" min-width="130px" align="center">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  80. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="配方颜色" min-width="130px" align="center">
  84. <template slot-scope="scope">
  85. <el-color-picker v-model="scope.row.tcolor" size="mini" :disabled="scope.row.NoEdit" style="margin:10px 0;" />
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="牲畜类别" min-width="150px" align="center">
  89. <template slot-scope="scope">
  90. <span v-if="scope.row.NoEdit">{{ scope.row.ccname }}</span>
  91. <el-select v-if="scope.row.Edit" v-model="scope.row.ccid" filterable placeholder="牲畜类别" class="filter-item" style="width:95%;padding:10px 0;" @change="changeLivestockType">
  92. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  93. </el-select>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="配方类型" min-width="150px" align="center">
  97. <template slot-scope="scope">
  98. <span v-if="scope.row.NoEdit">{{ scope.row.fttype }}</span>
  99. <el-select v-if="scope.row.Edit && scope.row.isCreate == true" v-model="scope.row.fttypeid" filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  100. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  101. </el-select>
  102. <el-select v-if="scope.row.Edit && scope.row.isUpdateSave == true" v-model="scope.row.fttypeid" disabled filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  103. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  104. </el-select>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="来源" min-width="110px" align="center">
  108. <template slot-scope="scope">
  109. <span>{{ scope.row.source }}</span>
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="备注" min-width="110px" align="center">
  113. <template slot-scope="scope">
  114. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  115. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width:95%;padding:10px 0;" />
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="版本号" min-width="110px" align="center">
  119. <template slot-scope="scope">
  120. <span>{{ scope.row.source }}</span>
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="是否启用" min-width="110px" align="center">
  124. <template slot-scope="scope">
  125. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  129. <template slot-scope="{row}">
  130. <!-- 新增 -->
  131. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData(row)">保存</el-button>
  132. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel(row)">取消</el-button>
  133. <!-- 编辑 -->
  134. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  135. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  136. <!-- 编辑保存 -->
  137. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData(row)">保存</el-button>
  138. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  139. <el-button class="miniSuccess" @click="handleFormulationEvaluation(row)">配方评估</el-button>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. </div>
  144. </div>
  145. <!-- 配方详情表 -->
  146. <div v-if="isDetail" ref="detail" class="detail" style="margin-top: 30px;">
  147. <div class="recipeTemplate">
  148. <p>配方详情表</p>
  149. </div>
  150. <div class="operation">
  151. <el-button class="success" @click="handleCreate2">新增</el-button>
  152. <el-button class="danger" @click="handleDelete2">删除</el-button>
  153. <el-button class="success" @click="handleSyntheticPremix">合成预混料</el-button>
  154. <div ref="selectInput2" class="filter-item selectInput" style="margin: 0 10px;">
  155. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  156. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  157. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  158. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  159. <li>
  160. <a style="width: 130px;">饲料名称</a>
  161. <el-select v-model="table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  162. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  163. </el-select>
  164. </li>
  165. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  166. <li><a style="width: 130px;">重量</a><el-input v-model="table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  167. <li>
  168. <a style="width: 130px;">搅拌延时</a>
  169. <el-select v-model="table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;" clearable>
  170. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  171. </el-select>
  172. </li>
  173. <li>
  174. <a style="width: 130px;">是否锁定牛头数比例</a>
  175. <el-select v-model="table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;" clearable>
  176. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  177. </el-select>
  178. </li>
  179. <li><a style="width: 130px;">顺序</a><el-input v-model="table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  180. <li>
  181. <div style="float: right;">
  182. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  183. <el-button class="miniSuccess" @click="handleSearch2">搜索</el-button>
  184. </div>
  185. </li>
  186. </ul>
  187. </div>
  188. <el-button class="successBorder" @click="handleSearch2">查询</el-button>
  189. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  190. </div>
  191. <div class="table2" style="min-height: 400px;">
  192. <el-table
  193. id="table2"
  194. ref="table2"
  195. :key="table2.tableKey"
  196. v-loading="table2.listLoading"
  197. element-loading-text="给我一点时间"
  198. :data="table2.list"
  199. border
  200. fit
  201. highlight-current-row
  202. style="width: 98%;"
  203. :row-style="rowStyle"
  204. :cell-style="cellStyle"
  205. class="elTable table-fixed"
  206. row-key="id"
  207. :summary-method="getSummaries"
  208. show-summary
  209. @selection-change="handleSelectionChange2"
  210. >
  211. <el-table-column type="selection" width="60" />
  212. <el-table-column label="序号" align="center" type="index" width="50px" />
  213. <el-table-column label="饲料组" min-width="110px" align="center">
  214. <template slot-scope="scope">
  215. <span v-if="scope.row.groupNoEdit">{{ scope.row.feedgroup }}</span>
  216. <el-input v-if="scope.row.groupEdit" v-model="scope.row.feedgroup" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  217. </template>
  218. </el-table-column>
  219. <el-table-column label="饲料名称" min-width="130px" align="center">
  220. <template slot-scope="scope">
  221. <span v-if="scope.row.NoEdit">{{ scope.row.fname }}</span>
  222. <el-select v-if="scope.row.Edit" v-model="scope.row.fid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  223. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  224. </el-select>
  225. </template>
  226. </el-table-column>
  227. <el-table-column label="重量(KG)" prop="fweight" min-width="100px" align="center">
  228. <template slot-scope="scope">
  229. <span v-if="scope.row.NoEdit">{{ scope.row.fweight }}</span>
  230. <el-input v-if="scope.row.Edit" v-model="scope.row.fweight" placeholder="重量" step="0.01" type="number" style="width:95%;padding:10px 0;" />
  231. </template>
  232. </el-table-column>
  233. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  234. <template slot-scope="scope">
  235. <span v-if="scope.row.NoEdit">{{ scope.row.autosecond }}</span>
  236. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  237. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  238. </el-select>
  239. </template>
  240. </el-table-column>
  241. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="110px" align="center">
  242. <template slot-scope="scope">
  243. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  244. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  245. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  246. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  247. </el-select>
  248. </template>
  249. </el-table-column>
  250. <el-table-column label="顺序" min-width="100px" align="center">
  251. <template slot-scope="scope">
  252. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  253. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)" />
  254. </template>
  255. </el-table-column>
  256. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  257. <template slot-scope="{row}">
  258. <!-- 新增 -->
  259. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData2(row)">保存</el-button>
  260. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel2(row)">取消</el-button>
  261. <!-- 编辑 -->
  262. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate2(row)">编辑</el-button>
  263. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete2(row)">删除</el-button>
  264. <!-- 编辑保存 -->
  265. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData2(row)">保存</el-button>
  266. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel2(row)">取消</el-button>
  267. <!-- 拆分预混料 -->
  268. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false" class="miniSuccess" @click="handleSplitPremix(row)">拆分预混料</el-button>
  269. </template>
  270. </el-table-column>
  271. </el-table>
  272. </div>
  273. </div>
  274. <!-- 配方记录 -->
  275. <el-dialog :title="textMap[template.dialogStatus]" :destroy-on-close="true" :visible.sync="template.dialogFormVisible" :close-on-click-modal="false" width="90%">
  276. <div style="height: 400px;overflow: auto;margin-bottom: 30px;">
  277. <div ref="templateDialog" class="templateDialog">
  278. <div class="recipeTemplate">
  279. <p>配方模板表</p>
  280. </div>
  281. <div class="operation">
  282. <el-date-picker v-model="template.table.getdataListParm.parammaps.date" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  283. <!-- <el-button class="successBorder" @click="handleApplication">应用</el-button> -->
  284. </div>
  285. <div class="search">
  286. <el-select v-model="template.table.getdataListParm.parammaps.ccname" placeholder="牲畜类别" class="filter-item" clearable>
  287. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  288. </el-select>
  289. <el-select v-model="template.table.getdataListParm.parammaps.fttype" placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  290. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  291. </el-select>
  292. <el-select v-model="template.table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  293. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  294. </el-select>
  295. <div ref="selectInput" class="filter-item selectInput">
  296. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  297. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  298. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  299. <ul v-if="arrowUp" class="selectUl">
  300. <li><a>配方名称</a><el-input v-model="template.table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  301. <li><a>备注</a><el-input v-model="template.table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  302. <li><a>来源</a><el-input v-model="template.table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  303. <li>
  304. <div style="float: right;">
  305. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  306. <el-button class="miniSuccess" @click="handleDialogSearch">搜索</el-button>
  307. </div>
  308. </li>
  309. </ul>
  310. </div>
  311. <el-button class="successBorder" @click="handleDialogSearch">查询</el-button>
  312. <el-button class="successBorder" @click="handleDialogRefresh">重置</el-button>
  313. </div>
  314. <div class="table">
  315. <el-table
  316. :key="template.table.tableKey"
  317. v-loading="template.table.listLoading"
  318. element-loading-text="给我一点时间"
  319. :data="template.table.list"
  320. border
  321. fit
  322. highlight-current-row
  323. style="width: 98%;"
  324. :row-style="rowStyle"
  325. :cell-style="cellStyle"
  326. class="elTable table-fixed"
  327. @row-click="tableRowClickDialog"
  328. >
  329. <el-table-column label="序号" align="center" type="index" width="50px">
  330. <template slot-scope="scope">
  331. <span>{{ scope.$index + (template.table.pageNum-1) * template.table.pageSize + 1 }}</span>
  332. </template>
  333. </el-table-column>
  334. <el-table-column label="配方名称" min-width="130px" align="center">
  335. <template slot-scope="scope">
  336. <span>{{ scope.row.tname }}</span>
  337. </template>
  338. </el-table-column>
  339. <el-table-column label="配方颜色" min-width="130px" align="center">
  340. <template slot-scope="scope">
  341. <el-color-picker v-model="scope.row.tcolor" size="mini" disabled style="margin:10px 0;" />
  342. </template>
  343. </el-table-column>
  344. <el-table-column label="牲畜类别" min-width="150px" align="center">
  345. <template slot-scope="scope">
  346. <span>{{ scope.row.ccname }}</span>
  347. </template>
  348. </el-table-column>
  349. <el-table-column label="配方类型" min-width="150px" align="center">
  350. <template slot-scope="scope">
  351. <span>{{ scope.row.fttype }}</span>
  352. </template>
  353. </el-table-column>
  354. <el-table-column label="来源" min-width="110px" align="center">
  355. <template slot-scope="scope">
  356. <span>{{ scope.row.source }}</span>
  357. </template>
  358. </el-table-column>
  359. <el-table-column label="备注" min-width="110px" align="center">
  360. <template slot-scope="scope">
  361. <span>{{ scope.row.remark }}</span>
  362. </template>
  363. </el-table-column>
  364. <el-table-column label="是否启用" min-width="110px" align="center">
  365. <template slot-scope="scope">
  366. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  367. </template>
  368. </el-table-column>
  369. </el-table>
  370. </div>
  371. </div>
  372. <div v-if="isDetailDialog" class="detailDialog" style="margin-top: 30px;">
  373. <div class="recipeTemplate">
  374. <p>配方详情表</p>
  375. </div>
  376. <div class="operation">
  377. <div ref="selectInput2" class="filter-item selectInput">
  378. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  379. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  380. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  381. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  382. <li>
  383. <a style="width: 130px;">饲料名称</a>
  384. <el-select v-model="template.table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  385. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  386. </el-select>
  387. </li>
  388. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="template.table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  389. <li><a style="width: 130px;">重量</a><el-input v-model="template.table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  390. <li>
  391. <a style="width: 130px;">搅拌延时</a>
  392. <el-select v-model="template.table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;">
  393. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  394. </el-select>
  395. </li>
  396. <li>
  397. <a style="width: 130px;">是否锁定牛头数比例</a>
  398. <el-select v-model="template.table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;">
  399. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  400. </el-select>
  401. </li>
  402. <li><a style="width: 130px;">顺序</a><el-input v-model="template.table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  403. <li>
  404. <div style="float: right;">
  405. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  406. <el-button class="miniSuccess" @click="handleDialogSearch2">搜索</el-button>
  407. </div>
  408. </li>
  409. </ul>
  410. </div>
  411. <el-button class="successBorder" @click="handleDialogSearch2">查询</el-button>
  412. <el-button class="successBorder" @click="handleDialogRefresh2">重置</el-button>
  413. </div>
  414. <div class="table2">
  415. <el-table
  416. :key="template.table2.tableKey"
  417. v-loading="template.table2.listLoading"
  418. element-loading-text="给我一点时间"
  419. :data="template.table2.list"
  420. border
  421. fit
  422. highlight-current-row
  423. style="width: 98%;"
  424. :row-style="rowStyle"
  425. :cell-style="cellStyle"
  426. class="elTable table-fixed"
  427. row-key="id"
  428. >
  429. <el-table-column label="饲料组" min-width="130px" align="center">
  430. <template slot-scope="scope">
  431. <span>{{ scope.row.feedgroup }}</span>
  432. </template>
  433. </el-table-column>
  434. <el-table-column label="饲料名称" min-width="130px" align="center">
  435. <template slot-scope="scope">
  436. <span>{{ scope.row.fname }}</span>
  437. </template>
  438. </el-table-column>
  439. <el-table-column label="重量(KG)" min-width="130px" align="center">
  440. <template slot-scope="scope">
  441. <span>{{ scope.row.fweight }}</span>
  442. </template>
  443. </el-table-column>
  444. <el-table-column label="搅拌延时(min)" min-width="130px" align="center">
  445. <template slot-scope="scope">
  446. <span>{{ scope.row.autosecondname }}</span>
  447. </template>
  448. </el-table-column>
  449. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  450. <template slot-scope="scope">
  451. <span v-if="scope.row.islockcount == '0'">否</span>
  452. <span v-if="scope.row.islockcount == '1'">是</span>
  453. </template>
  454. </el-table-column>
  455. <el-table-column label="顺序" min-width="130px" align="center">
  456. <template slot-scope="scope">
  457. <span>{{ scope.row.sort }}</span>
  458. </template>
  459. </el-table-column>
  460. </el-table>
  461. </div>
  462. </div>
  463. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
  464. <el-button @click="template.dialogFormVisible = false; ">关闭</el-button>
  465. </div>
  466. </div>
  467. </el-dialog>
  468. <!-- 合成预混料 -->
  469. <el-dialog :title="textMap[detail.dialogStatus]" :destroy-on-close="true" :visible.sync="detail.dialogFormVisible" :close-on-click-modal="false" width="90%">
  470. <div class="detailDialog">
  471. <h2>饲料</h2>
  472. <div class="table1">
  473. <el-table
  474. :key="detail.tableKey"
  475. v-loading="detail.listLoading"
  476. element-loading-text="给我一点时间"
  477. :data="detail.list"
  478. fit
  479. highlight-current-row
  480. style="width: 100%;"
  481. :row-style="rowStyle"
  482. :cell-style="cellStyle"
  483. class="elTable table-fixed"
  484. show-summary
  485. >
  486. <el-table-column label="序号" align="center" type="index" width="50px" />
  487. <el-table-column label="饲料名称" min-width="130px" align="center">
  488. <template slot-scope="scope">
  489. <span>{{ scope.row.fname }}</span>
  490. </template>
  491. </el-table-column>
  492. <el-table-column prop="fweight" label="重量(KG)" />
  493. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  494. <template slot-scope="scope">
  495. <span>{{ scope.row.autosecond }}</span>
  496. </template>
  497. </el-table-column>
  498. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="130px" align="center">
  499. <template slot-scope="scope">
  500. <span v-if="scope.row.islockcount == '0'">否</span>
  501. <span v-if="scope.row.islockcount == '1'">是</span>
  502. </template>
  503. </el-table-column>
  504. <el-table-column label="顺序" min-width="110px" align="center">
  505. <template slot-scope="scope">
  506. <span>{{ scope.row.sort }}</span>
  507. </template>
  508. </el-table-column>
  509. </el-table>
  510. </div>
  511. <h2>合成预混料</h2>
  512. <div class="table2" style="margin-bottom: 50px;">
  513. <el-table
  514. :key="detail.tableKey2"
  515. v-loading="detail.listLoading2"
  516. element-loading-text="给我一点时间"
  517. :data="detail.list2"
  518. border
  519. fit
  520. highlight-current-row
  521. style="width: 100%;"
  522. :row-style="rowStyle"
  523. :cell-style="cellStyle"
  524. class="elTable table-fixed"
  525. >
  526. <el-table-column label="配方名称" min-width="130px" align="center">
  527. <template slot-scope="scope">
  528. <el-input v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  529. </template>
  530. </el-table-column>
  531. <el-table-column label="配方颜色11" min-width="130px" align="center">
  532. <template slot-scope="scope">
  533. <el-color-picker v-model="scope.row.tcolor" size="mini" style="margin:10px 0;" :disabled="detail.disabled" />
  534. </template>
  535. </el-table-column>
  536. <el-table-column label="牲畜类别" min-width="130px" align="center">
  537. <template slot-scope="scope">
  538. <el-select v-model="scope.row.ccid" placeholder="选择牲畜父类" class="filter-item" style="width:95%;padding:10px 0;" :disabled="detail.disabled" @change="changeLivestockType2">
  539. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  540. </el-select>
  541. </template>
  542. </el-table-column>
  543. <el-table-column label="配方类型" min-width="110px" align="center">
  544. <template slot-scope="scope">
  545. <span>{{ scope.row.fttype }}</span>
  546. </template>
  547. </el-table-column>
  548. <el-table-column label="来源" min-width="110px" align="center">
  549. <template slot-scope="scope">
  550. <span>{{ scope.row.source }}</span>
  551. </template>
  552. </el-table-column>
  553. <el-table-column label="备注" min-width="130px" align="center">
  554. <template slot-scope="scope">
  555. <el-input v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  556. </template>
  557. </el-table-column>
  558. <el-table-column label="是否启用" min-width="130px" align="center">
  559. <template slot-scope="scope">
  560. <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" :disabled="detail.disabled" />
  561. </template>
  562. </el-table-column>
  563. </el-table>
  564. </div>
  565. <div slot="footer" class="dialog-footer" style="bottom: -50px;">
  566. <el-button class="cancelClose" @click="detail.dialogFormVisible = false; ">关闭</el-button>
  567. <el-button class="success" :disabled="isokDisable" @click="syntheticPremixData()">确认</el-button>
  568. </div>
  569. </div>
  570. </el-dialog>
  571. </div>
  572. </template>
  573. <script>
  574. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig, formatNum } from '@/api/common'
  575. import Sortable from 'sortablejs'
  576. import { MessageBox } from 'element-ui'
  577. import Cookies from 'js-cookie'
  578. import { json2excel } from '@/utils/index.js'
  579. import { getToken } from '@/utils/auth'
  580. export default {
  581. name: 'RecipeTemplate',
  582. data() {
  583. return {
  584. requestParams: [
  585. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] },
  586. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['配方类型'] },
  587. { name: 'getFeedAndPre', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  588. ],
  589. enableList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否启用
  590. lockBullsList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否锁定牛头数比例
  591. livestockTypeList: [], // 牲畜类别
  592. formulaTypeList: [], // 配方类型
  593. feedNameList: [], // 饲料名称
  594. mixingDelayList: [{ id: '0', name: '0' }, { id: '1', name: '1' }, { id: '2', name: '2' }, { id: '3', name: '3' }, { id: '4', name: '4' }, { id: '5', name: '5' }, { id: '6', name: '6' }, { id: '7', name: '7' }, { id: '8', name: '8' }, { id: '9', name: '9' }, { id: '10', name: '10' }, { id: '11', name: '11' }, { id: '12', name: '12' }, { id: '13', name: '13' }, { id: '14', name: '14' }, { id: '15', name: '15' }], // 搅拌延时
  595. selectHistoryTimeList: [{ id: 0, name: '2020-06-10' }, { id: 1, name: '2020-06-11' }, { id: 2, name: '2020-06-12' }, { id: 3, name: '2020-06-13' }], // 请选择历史记录时间
  596. sourceList: [{ id: 0, name: '自定义' }, { id: 1, name: '集团下发' }, { id: 2, name: '导入' }], // 导入
  597. arrowDown: true,
  598. arrowUp: false,
  599. table: {
  600. getdataListParm: {
  601. name: 'getFTList',
  602. page: 1,
  603. offset: 1,
  604. pagecount: 30,
  605. returntype: 'Map',
  606. parammaps: {
  607. pastureid: Cookies.get('pastureid'),
  608. tname: '',
  609. ccid: '',
  610. ccname: '',
  611. fttypeid: '',
  612. fttype: '',
  613. remark: '',
  614. enable: ''
  615. }
  616. },
  617. tableKey: 0,
  618. list: [],
  619. total: 0,
  620. listLoading: true,
  621. temp: {}
  622. },
  623. lockCount: {
  624. getdataListParm: {
  625. name: 'getSysoptEnable',
  626. page: 1,
  627. offset: 1,
  628. pagecount: 30,
  629. returntype: 'Map',
  630. parammaps: {
  631. pastureid: Cookies.get('pastureid'),
  632. inforname: 'isLockCount'
  633. }
  634. },
  635. isLockCount: false // 是否显示是否锁定牛头数比例
  636. },
  637. isDetail: false,
  638. arrowDown2: true,
  639. arrowUp2: false,
  640. table2: {
  641. getdataListParm: {
  642. name: 'getFTdetailList',
  643. page: 1,
  644. offset: 1,
  645. pagecount: 10,
  646. returntype: 'Map',
  647. parammaps: {
  648. pastureid: Cookies.get('pastureid'),
  649. fname: '',
  650. feedgroup: '',
  651. fweight: '',
  652. autosecondname: '',
  653. islockcount: '',
  654. sort: ''
  655. }
  656. },
  657. tableKey: 0,
  658. list: [],
  659. total: 0,
  660. listLoading: true,
  661. temp: {}
  662. },
  663. isDetailDialog: false,
  664. template: {
  665. dialogFormVisible: false,
  666. dialogStatus: '',
  667. table: {
  668. getdataListParm: {
  669. name: 'getFTListDate',
  670. page: 1,
  671. offset: 1,
  672. pagecount: 10,
  673. returntype: 'Map',
  674. parammaps: {
  675. pastureid: Cookies.get('pastureid'),
  676. tname: '',
  677. ccid: '',
  678. ccname: '',
  679. fttype: '',
  680. remark: '',
  681. enable: '',
  682. date: '',
  683. source: ''
  684. }
  685. },
  686. tableKey: 0,
  687. total: 0,
  688. listLoading: true,
  689. list: []
  690. },
  691. table2: {
  692. getdataListParm: {
  693. name: 'getFTdetailListDate',
  694. page: 1,
  695. offset: 1,
  696. pagecount: 10,
  697. returntype: 'Map',
  698. parammaps: {
  699. pastureid: Cookies.get('pastureid'),
  700. fname: '',
  701. fweight: '',
  702. islockcount: '',
  703. sort: '',
  704. feedgroup: '',
  705. autosecondname: ''
  706. }
  707. },
  708. tableKey: 0,
  709. total: 0,
  710. listLoading: true,
  711. list: []
  712. },
  713. // 历史日期
  714. getdataDateParm: {
  715. name: 'getFTMaxDate',
  716. page: 1,
  717. offset: 1,
  718. pagecount: 10,
  719. returntype: 'Map',
  720. parammaps: {
  721. pastureid: Cookies.get('pastureid')
  722. }
  723. }
  724. },
  725. detail: {
  726. dialogFormVisible: false,
  727. dialogStatus: '',
  728. tableKey: 0,
  729. total: 0,
  730. listLoading: true,
  731. list: [],
  732. tableKey2: 0,
  733. total2: 0,
  734. listLoading2: false,
  735. list2: [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }],
  736. getdataListParm: {
  737. name: 'getFTDetailCompare',
  738. page: 1,
  739. offset: 1,
  740. pagecount: 10,
  741. returntype: 'Map',
  742. parammaps: {}
  743. },
  744. list3: [],
  745. disabled: false,
  746. getdataListParm2: {
  747. name: 'getFTCompare',
  748. page: 1,
  749. offset: 1,
  750. pagecount: 10,
  751. returntype: 'Map',
  752. parammaps: {}
  753. }
  754. },
  755. selectList: [],
  756. selectList2: [],
  757. textMap: {
  758. RecipeRecord: '配方记录',
  759. SyntheticPremix: '合成预混料',
  760. historyRecord: '历史记录'
  761. },
  762. requestParam: {},
  763. download: {
  764. getdataListParm: {
  765. name: 'getFTList',
  766. page: 1,
  767. offset: 1,
  768. pagecount: 0,
  769. returntype: 'Map',
  770. parammaps: {
  771. pastureid: Cookies.get('pastureid'),
  772. tname: '',
  773. ccid: '',
  774. ccname: '',
  775. fttypeid: '',
  776. fttype: '',
  777. remark: '',
  778. enable: ''
  779. }
  780. },
  781. list: []
  782. },
  783. historyRecord: {
  784. dialogStatus: '',
  785. dialogFormVisible: false
  786. },
  787. isokDisable: false,
  788. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  789. cellStyle: { padding: 0 + 'px' },
  790. dropState: false
  791. }
  792. },
  793. computed: {
  794. // 设置请求头
  795. headers() {
  796. return {
  797. token: getToken()
  798. }
  799. },
  800. uploadData() {
  801. return {
  802. name: '颛孙洋洋-配方模板',
  803. importParams: '配方名称, 牲畜类别, 配方类型, 备注, 是否启用, 饲料组, 饲料名称, 重量(kg), 搅拌延时(min), 是否锁定牛头数比例',
  804. sheetname: 'SheetJS'
  805. }
  806. },
  807. // 设置上传地址
  808. uploadExcelUrl() {
  809. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  810. }
  811. },
  812. mounted() {
  813. document.addEventListener('click', (e) => {
  814. if (this.$refs.selectInput !== undefined) {
  815. if (!this.$refs.selectInput.contains(e.target)) {
  816. this.arrowDown = true
  817. this.arrowUp = false
  818. } else {
  819. this.arrowDown = false
  820. this.arrowUp = true
  821. }
  822. }
  823. if (this.$refs.selectInput2 !== undefined) {
  824. if (!this.$refs.selectInput2.contains(e.target)) {
  825. this.arrowDown2 = true
  826. this.arrowUp2 = false
  827. } else {
  828. this.arrowDown2 = false
  829. this.arrowUp2 = true
  830. }
  831. }
  832. })
  833. },
  834. created() {
  835. this.getList()
  836. this.getDownList()
  837. this.getIsLockCount()
  838. },
  839. methods: {
  840. getSummaries(param) {
  841. console.log(param, '====')
  842. const { columns, data } = param
  843. const sums = []
  844. columns.forEach((column, index) => {
  845. if (index === 0) {
  846. sums[index] = '总价'
  847. return
  848. }
  849. const values = data.map(item => Number(item[column.property]))
  850. if (!values.every(value => isNaN(value))) {
  851. sums[index] = values.reduce((prev, curr) => {
  852. const value = Number(curr)
  853. if (!isNaN(value)) {
  854. return prev + curr
  855. } else {
  856. return prev
  857. }
  858. }, 0)
  859. sums[index] += '(干物质量:是待发值)'
  860. // 后台待发
  861. // sums[index] += '(干物质量:' + param.data[0].feedgroup + ')'
  862. } else {
  863. sums[index] = ''
  864. }
  865. })
  866. return sums
  867. },
  868. handleHistory() {
  869. MessageBox.confirm('是否确认生成历史?', {
  870. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  871. }).then(() => {
  872. this.requestParam.name = 'creatFTdate'
  873. this.requestParam.parammaps = {}
  874. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  875. PostDataByName(this.requestParam).then(response => {
  876. console.log('生成历史保存发送参数', this.requestParam)
  877. if (response.msg !== 'fail') {
  878. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  879. } else {
  880. failproccess(response, this.$notify)
  881. }
  882. })
  883. })
  884. },
  885. getDownList() {
  886. GetDataByNames(this.requestParams).then(response => {
  887. this.livestockTypeList = response.data.getDictByName.list
  888. this.formulaTypeList = response.data.getDictByName2.list
  889. this.feedNameList = response.data.getFeedAndPre.list
  890. })
  891. },
  892. // -------------------模板-----------------------------
  893. getList() {
  894. this.table.listLoading = true
  895. GetDataByName(this.table.getdataListParm).then(response => {
  896. console.log('table数据', response.data.list)
  897. if (response.data.list !== null) {
  898. for (let i = 0; i < response.data.list.length; i++) {
  899. this.$set(response.data.list[i], 'Edit', false) // 编辑
  900. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  901. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  902. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  903. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  904. }
  905. this.table.list = response.data.list
  906. this.table.pageNum = response.data.pageNum
  907. this.table.pageSize = response.data.pageSize
  908. this.table.total = response.data.total
  909. } else {
  910. this.table.list = []
  911. }
  912. setTimeout(() => {
  913. this.table.listLoading = false
  914. }, 100)
  915. })
  916. },
  917. handleSearch() {
  918. console.log('点击了查询')
  919. this.table.getdataListParm.offset = 1
  920. this.getList()
  921. this.arrowDown = true
  922. this.arrowUp = false
  923. },
  924. handleRefresh() {
  925. console.log('点击了重置')
  926. this.table.getdataListParm.offset = 1
  927. this.table.getdataListParm.parammaps.ccid = ''
  928. this.table.getdataListParm.parammaps.ccname = ''
  929. this.table.getdataListParm.parammaps.fttype = ''
  930. this.table.getdataListParm.parammaps.tname = ''
  931. this.table.getdataListParm.parammaps.remark = ''
  932. this.table.getdataListParm.parammaps.enable = ''
  933. this.table.getdataListParm.parammaps.source = ''
  934. this.getList()
  935. },
  936. // 模板新增
  937. handleCreate() {
  938. console.log('点击了新增')
  939. // 编辑true/不可编辑false
  940. // 新增操true,编辑false,编辑保存false
  941. for (let i = 0; i < this.table.list.length; i++) {
  942. if (this.table.list[i].Edit === true) {
  943. console.log(123)
  944. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  945. return false
  946. }
  947. }
  948. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'tname': '', 'tcolor': '#ccc', 'ccid': '', 'ccname': '', 'fttype': '', 'fttypeid': '', 'source': '自定义', 'remark': '' })
  949. console.log(this.table.list)
  950. },
  951. // 畜生类别
  952. changeLivestockType(item) {
  953. this.table.temp.ccname = this.livestockTypeList.find(obj => obj.value === item).label
  954. },
  955. // 配方类型
  956. changeFormulaType(item) {
  957. this.table.temp.fttype = this.formulaTypeList.find(obj => obj.value === item).label
  958. },
  959. createData(row) {
  960. console.log('点击了新增保存', row)
  961. this.table.temp.tname = row.tname
  962. this.table.temp.tcolor = row.tcolor
  963. this.table.temp.ccid = row.ccid
  964. this.table.temp.ccname = this.table.temp.ccname
  965. this.table.temp.fttype = this.table.temp.fttype
  966. this.table.temp.fttypeid = row.fttypeid
  967. this.table.temp.source = row.source
  968. this.table.temp.remark = row.remark
  969. this.table.temp.enable = row.enable
  970. this.table.temp.pastureid = Cookies.get('pastureid')
  971. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  972. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  973. return false
  974. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  975. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  976. return false
  977. } else if (this.table.temp.tname == '') {
  978. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  979. return false
  980. } else if (this.table.temp.ccid == '') {
  981. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  982. return false
  983. } else if (this.table.temp.fttypeid == '') {
  984. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  985. return false
  986. }
  987. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  988. if (pattern.test(this.table.temp.tname)) {
  989. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  990. return false
  991. }
  992. console.log(this.table.temp)
  993. this.isokDisable = true
  994. setTimeout(() => {
  995. this.isokDisable = false
  996. }, 1000)
  997. this.requestParam.name = 'insertFT'
  998. this.requestParam.parammaps = this.table.temp
  999. PostDataByName(this.requestParam).then(response => {
  1000. console.log('新增保存发送参数', this.requestParam)
  1001. if (response.msg !== 'fail') {
  1002. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1003. this.getList()
  1004. } else {
  1005. failproccess(response, this.$notify)
  1006. }
  1007. })
  1008. },
  1009. createCancel(row) {
  1010. console.log('点击了新增取消')
  1011. for (let i = 0; i < this.table.list.length; i++) {
  1012. if (row.myId === this.table.list[i].myId) {
  1013. var listIndex = this.table.list.indexOf(this.table.list[i])
  1014. }
  1015. if (listIndex > -1) {
  1016. this.table.list.splice(listIndex, 1)
  1017. return
  1018. }
  1019. }
  1020. },
  1021. // 模板编辑
  1022. handleUpdate(row) {
  1023. for (let i = 0; i < this.table.list.length; i++) {
  1024. if (this.table.list[i].Edit == true) {
  1025. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1026. return false
  1027. }
  1028. }
  1029. // 编辑true,不可编辑false
  1030. row.Edit = true
  1031. row.NoEdit = false
  1032. // 新增false,编辑false,编辑保存true
  1033. row.isCreate = false
  1034. row.isUpdate = false
  1035. row.isUpdateSave = true
  1036. row.ccid = String(row.ccid)
  1037. row.fttypeid = String(row.fttypeid)
  1038. this.table.temp.ccname = row.ccname
  1039. this.table.temp.fttype = row.fttype
  1040. },
  1041. updateData(row) {
  1042. console.log('点击了编辑保存', row)
  1043. this.table.temp.tname = row.tname
  1044. this.table.temp.tcolor = row.tcolor
  1045. this.table.temp.ccid = row.ccid
  1046. this.table.temp.fttypeid = row.fttypeid
  1047. this.table.temp.source = row.source
  1048. this.table.temp.remark = row.remark
  1049. this.table.temp.enable = row.enable
  1050. this.table.temp.ccname = this.table.temp.ccname
  1051. this.table.temp.fttype = this.table.temp.fttype
  1052. this.table.temp.pastureid = row.pastureid
  1053. this.table.temp.id = row.id
  1054. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1055. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  1056. return false
  1057. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1058. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  1059. return false
  1060. } else if (this.table.temp.tname == '') {
  1061. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1062. return false
  1063. } else if (this.table.temp.ccid == '') {
  1064. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1065. return false
  1066. } else if (this.table.temp.fttypeid == '') {
  1067. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  1068. return false
  1069. }
  1070. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1071. if (pattern.test(this.table.temp.tname)) {
  1072. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  1073. return false
  1074. }
  1075. console.log(this.table.temp)
  1076. this.isokDisable = true
  1077. setTimeout(() => {
  1078. this.isokDisable = false
  1079. }, 1000)
  1080. this.requestParam.name = 'updateFT'
  1081. this.requestParam.parammaps = this.table.temp
  1082. PostDataByName(this.requestParam).then(response => {
  1083. console.log('新增保存发送参数', this.requestParam)
  1084. if (response.msg !== 'fail') {
  1085. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1086. this.getList()
  1087. } else {
  1088. failproccess(response, this.$notify)
  1089. }
  1090. })
  1091. },
  1092. updateCancel(row) {
  1093. console.log('点击了编辑取消')
  1094. // 编辑false,不可编辑true
  1095. row.Edit = false
  1096. row.NoEdit = true
  1097. // 新增false,编辑true,编辑保存false
  1098. row.isCreate = false
  1099. row.isUpdate = true
  1100. row.isUpdateSave = false
  1101. this.getList()
  1102. },
  1103. // 删除
  1104. handleRowDelete(row) {
  1105. console.log('点击了行内删除')
  1106. MessageBox.confirm('是否确认删除此信息?', {
  1107. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1108. }).then(() => {
  1109. this.requestParam.common = { 'returnmap': '0' }
  1110. this.requestParam.data = []
  1111. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1112. pastureid: row.pastureid,
  1113. id: row.id
  1114. }}
  1115. this.requestParam.data[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1116. pastureid: row.pastureid,
  1117. id: row.id
  1118. }}
  1119. ExecDataByConfig(this.requestParam).then(response => {
  1120. console.log('新增保存发送参数', this.requestParam)
  1121. if (response.msg === 'fail') {
  1122. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1123. } else {
  1124. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1125. this.getList()
  1126. this.isDetail = false
  1127. }
  1128. })
  1129. }).catch(() => {
  1130. this.$message({ type: 'info', message: '已取消删除' })
  1131. })
  1132. },
  1133. handleSelectionChange(val) {
  1134. console.log('勾选数据', val)
  1135. this.selectList = val
  1136. },
  1137. handleDelete() {
  1138. console.log('点击了删除')
  1139. if (this.selectList.length == 0) {
  1140. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1141. } else {
  1142. MessageBox.confirm('是否确认删除此信息?', {
  1143. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1144. }).then(() => {
  1145. console.log(this.selectList)
  1146. this.requestParam.common = { 'returnmap': '0' }
  1147. this.requestParam.data = []
  1148. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1149. this.requestParam.data[0].children = []
  1150. this.requestParam.data[0].children[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1151. id: '@insertSpotList.id',
  1152. pastureid: '@insertSpotList.pastureid'
  1153. }}
  1154. this.requestParam.data[0].children[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1155. id: '@insertSpotList.id',
  1156. pastureid: '@insertSpotList.pastureid'
  1157. }}
  1158. ExecDataByConfig(this.requestParam).then(response => {
  1159. console.log('删除保存发送参数', this.requestParam)
  1160. if (response.msg === 'fail') {
  1161. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1162. } else {
  1163. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1164. this.getList()
  1165. }
  1166. })
  1167. })
  1168. }
  1169. },
  1170. // 复制
  1171. handleCopy() {
  1172. if (this.selectList.length == 0) {
  1173. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1174. } else {
  1175. MessageBox.confirm('是否确认复制此信息?', {
  1176. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1177. }).then(() => {
  1178. console.log(this.selectList)
  1179. this.requestParam.common = { 'returnmap': '0' }
  1180. this.requestParam.data = []
  1181. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1182. this.requestParam.data[0].children = []
  1183. this.requestParam.data[0].children[0] = { 'name': 'copyFT', 'type': 'e', 'parammaps': {
  1184. ftid: '@insertSpotList.id',
  1185. pastureid: '@insertSpotList.pastureid'
  1186. }}
  1187. ExecDataByConfig(this.requestParam).then(response => {
  1188. console.log('复制保存发送参数', this.requestParam)
  1189. if (response.msg === 'fail') {
  1190. this.$notify({ title: '复制失败', message: response.data, type: 'warning', duration: 2000 })
  1191. } else {
  1192. this.$notify({ title: '', message: '复制成功', type: 'success', duration: 2000 })
  1193. this.getList()
  1194. }
  1195. })
  1196. })
  1197. }
  1198. },
  1199. // 配方记录
  1200. handleRecipeRecord() {
  1201. console.log('点击了配方记录')
  1202. this.template.dialogStatus = 'RecipeRecord'
  1203. this.template.dialogFormVisible = true
  1204. this.template.table.getdataListParm.parammaps.ccname = ''
  1205. this.template.table.getdataListParm.parammaps.fttype = ''
  1206. this.template.table.getdataListParm.parammaps.enable = ''
  1207. this.template.table.getdataListParm.parammaps.tname = ''
  1208. this.template.table.getdataListParm.parammaps.remark = ''
  1209. this.template.table.getdataListParm.parammaps.source = ''
  1210. this.template.table.getdataListParm.offset = 1
  1211. this.getDateList()
  1212. this.isDetailDialog = false
  1213. },
  1214. // 历史时间
  1215. getDateList() {
  1216. GetDataByName(this.template.getdataDateParm).then(response => {
  1217. console.log('table数据', response.data.list)
  1218. if (response.data.list !== null) {
  1219. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  1220. this.getTemplateDialogList()
  1221. } else {
  1222. this.template.table.getdataListParm.parammaps.date = ''
  1223. }
  1224. })
  1225. },
  1226. // 配方记录-模板
  1227. getTemplateDialogList() {
  1228. this.template.table.listLoading = true
  1229. GetDataByName(this.template.table.getdataListParm).then(response => {
  1230. console.log('table数据', response.data.list)
  1231. if (response.data.list !== null) {
  1232. this.template.table.list = response.data.list
  1233. this.template.table.pageNum = response.data.pageNum
  1234. this.template.table.pageSize = response.data.pageSize
  1235. this.template.table.total = response.data.total
  1236. } else {
  1237. this.template.table.list = []
  1238. }
  1239. setTimeout(() => {
  1240. this.template.table.listLoading = false
  1241. }, 100)
  1242. })
  1243. },
  1244. handleDialogSearch() {
  1245. this.template.table.getdataListParm.offset = 1
  1246. this.getTemplateDialogList()
  1247. this.arrowDown = true
  1248. this.arrowUp = false
  1249. },
  1250. handleDialogRefresh() {
  1251. this.template.table.getdataListParm.parammaps.ccname = ''
  1252. this.template.table.getdataListParm.parammaps.fttype = ''
  1253. this.template.table.getdataListParm.parammaps.enable = ''
  1254. this.template.table.getdataListParm.parammaps.tname = ''
  1255. this.template.table.getdataListParm.parammaps.remark = ''
  1256. this.template.table.getdataListParm.parammaps.source = ''
  1257. this.template.table.getdataListParm.offset = 1
  1258. this.getTemplateDialogList()
  1259. },
  1260. // 配方记录-模板行点击
  1261. tableRowClickDialog(row, column, event) {
  1262. console.log('配方记录-模板行点击')
  1263. this.isDetailDialog = true
  1264. this.template.table2.getdataListParm.parammaps.ftid = row.id
  1265. this.getDialogList()
  1266. this.getDownList()
  1267. },
  1268. getDialogList() {
  1269. this.template.table2.listLoading = true
  1270. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1271. console.log('table数据', response.data.list)
  1272. if (response.data.list !== null) {
  1273. this.template.table2.list = response.data.list
  1274. this.template.table2.pageNum = response.data.pageNum
  1275. this.template.table2.pageSize = response.data.pageSize
  1276. this.template.table2.total = response.data.total
  1277. } else {
  1278. this.template.table2.list = []
  1279. }
  1280. setTimeout(() => {
  1281. this.template.table2.listLoading = false
  1282. }, 100)
  1283. })
  1284. },
  1285. handleDialogSearch2() {
  1286. console.log('点击了查询')
  1287. this.arrowDown2 = true
  1288. this.arrowUp2 = false
  1289. this.template.table2.getdataListParm.offset = 1
  1290. this.getDialogList2()
  1291. },
  1292. handleDialogRefresh2() {
  1293. console.log('点击了重置')
  1294. this.template.table2.getdataListParm.parammaps.fname = ''
  1295. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  1296. this.template.table2.getdataListParm.parammaps.fweight = ''
  1297. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  1298. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  1299. this.template.table2.getdataListParm.parammaps.sort = ''
  1300. this.template.table2.getdataListParm.offset = 1
  1301. this.getDialogList2()
  1302. },
  1303. getDialogList2() {
  1304. this.template.table2.listLoading = true
  1305. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1306. console.log('table数据', response.data.list)
  1307. if (response.data.list !== null) {
  1308. this.template.table2.list = response.data.list
  1309. this.template.table2.pageNum = response.data.pageNum
  1310. this.template.table2.pageSize = response.data.pageSize
  1311. this.template.table2.total = response.data.total
  1312. } else {
  1313. this.template.table2.list = []
  1314. }
  1315. this.$nextTick(function() {
  1316. window.scrollTo({
  1317. 'top': this.$refs.templateDialog.clientHeight
  1318. })
  1319. })
  1320. setTimeout(() => {
  1321. this.template.table2.listLoading = false
  1322. }, 100)
  1323. })
  1324. },
  1325. // 历史记录
  1326. handleHistoryRecord() {
  1327. console.log('点击了历史记录,页面待画')
  1328. this.historyRecord.dialogStatus = 'historyRecord'
  1329. this.historyRecord.dialogFormVisible = true
  1330. const vue = this
  1331. var myComponent = () => import('./historyRecord.vue')
  1332. return vue.historyRecord.myComponent = myComponent
  1333. },
  1334. // 导出
  1335. handleExport(item) {
  1336. if (item == 1) {
  1337. console.log('点击了导出模板')
  1338. } else {
  1339. console.log('点击了导出数据')
  1340. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1341. GetDataByName(this.download.getdataListParm).then(response => {
  1342. if (response.data.list !== null) {
  1343. for (let i = 0; i < response.data.list.length; i++) {
  1344. if (response.data.list[i].islockcount == 0) {
  1345. this.$set(response.data.list[i], 'islockcount', '否')
  1346. } else {
  1347. this.$set(response.data.list[i], 'islockcount', '是')
  1348. }
  1349. if (response.data.list[i].enable == 0) {
  1350. this.$set(response.data.list[i], 'enable', '否')
  1351. } else {
  1352. this.$set(response.data.list[i], 'enable', '是')
  1353. }
  1354. }
  1355. this.download.list = response.data.list
  1356. } else {
  1357. this.download.list = []
  1358. }
  1359. var excelDatas = [
  1360. {
  1361. tHeader: ['配方名称', '牲畜类别', '配方类型', '来源', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '顺序'],
  1362. filterVal: ['tname', 'ccname', 'fttype', 'source', 'remark', 'enable', 'feedgroup', 'fname', 'fweight', 'autosecond', 'islockcount', 'sort'],
  1363. tableDatas: this.download.list,
  1364. sheetName: 'Sheet1'
  1365. }
  1366. ]
  1367. json2excel(excelDatas, '配方模板', true, 'xlsx')
  1368. })
  1369. }
  1370. },
  1371. beforeImport(file) {
  1372. const isLt2M = file.size / 1024 / 1024 < 2
  1373. if (!isLt2M) {
  1374. this.$message.error('上传文件大小不能超过 2MB!')
  1375. }
  1376. return isLt2M
  1377. },
  1378. handleImportSuccess(res, file) {
  1379. this.getList()
  1380. if (res.msg === 'ok') {
  1381. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  1382. if (res.data.err_count > 0) {
  1383. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  1384. import('@/vendor/Export2Excel').then(excel => {
  1385. const list1 = res.data.result
  1386. const tHeader = [
  1387. '配方名称', '牲畜类别', '配方类型', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '错误信息'
  1388. ]
  1389. const filterVal = [
  1390. '配方名称', '牲畜类别', '配方类型', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', 'error_msg'
  1391. ]
  1392. const data1 = this.formatJson(filterVal, list1)
  1393. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '配方模板导入报错信息', autoWidth: true, bookType: 'xlsx' })
  1394. })
  1395. }
  1396. } else {
  1397. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  1398. }
  1399. },
  1400. formatJson(filterVal, jsonData) {
  1401. return jsonData.map(v =>
  1402. filterVal.map(j => {
  1403. if (j === 'timestamp') {
  1404. return parseTime(v[j])
  1405. } else {
  1406. return v[j]
  1407. }
  1408. })
  1409. )
  1410. },
  1411. changeDate() {
  1412. this.getTemplateDialogList()
  1413. },
  1414. // 应用
  1415. handleApplication() {
  1416. console.log('点击了应用')
  1417. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  1418. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1419. }).then(() => {
  1420. this.requestParam.name = 'applyFTdate'
  1421. this.requestParam.parammaps = {}
  1422. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1423. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1424. PostDataByName(this.requestParam).then(response => {
  1425. if (response.msg === 'fail') {
  1426. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1427. } else {
  1428. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1429. this.getTemplateDialogList()
  1430. this.getList()
  1431. }
  1432. })
  1433. }).catch(() => {
  1434. this.$message({ type: 'info', message: '已取消应用' })
  1435. })
  1436. },
  1437. // 模板行点击
  1438. tableRowClick(row, column, event) {
  1439. console.log(row, column, event)
  1440. for (let i = 0; i < this.table.list.length; i++) {
  1441. if (this.table.list[i].Edit == true) {
  1442. return false
  1443. }
  1444. }
  1445. if (column.label !== '操作') {
  1446. this.isDetail = true // 点击行显示详情
  1447. this.table2.getdataListParm.parammaps.ftid = row.id
  1448. this.table2.getdataListParm.parammaps.fttypeid = row.fttypeid
  1449. this.getList2()
  1450. this.getDownList()
  1451. }
  1452. },
  1453. // -------------------详情-----------------------------
  1454. // 获取是否显示是否锁定牛头数
  1455. getIsLockCount() {
  1456. GetDataByName(this.lockCount.getdataListParm).then(response => {
  1457. console.log(response.data.list)
  1458. if (response.data.list[0].inforvalue == 0) {
  1459. this.lockCount.isLockCount = false
  1460. } else {
  1461. this.lockCount.isLockCount = true
  1462. }
  1463. })
  1464. },
  1465. // 详情
  1466. getList2() {
  1467. this.table2.listLoading = true
  1468. GetDataByName(this.table2.getdataListParm).then(response => {
  1469. console.log('table数据', response.data.list)
  1470. if (response.data.list !== null) {
  1471. for (let i = 0; i < response.data.list.length; i++) {
  1472. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1473. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1474. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  1475. this.$set(response.data.list[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1476. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  1477. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1478. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1479. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1480. }
  1481. this.table2.list = response.data.list
  1482. this.table2.pageNum = response.data.pageNum
  1483. this.table2.pageSize = response.data.pageSize
  1484. this.table2.total = response.data.total
  1485. this.rowDrop()
  1486. } else {
  1487. this.table2.list = []
  1488. }
  1489. this.$nextTick(function() {
  1490. console.log(this.$refs)
  1491. console.log(this.$refs.template.clientHeight)
  1492. window.scrollTo({
  1493. 'top': this.$refs.template.clientHeight
  1494. })
  1495. })
  1496. setTimeout(() => {
  1497. this.table2.listLoading = false
  1498. }, 100)
  1499. })
  1500. },
  1501. // 行拖拽
  1502. rowDrop() {
  1503. console.log(1111)
  1504. console.log(document.querySelector('#table2 .el-table__body-wrapper tbody'))
  1505. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  1506. // this.sorTable()
  1507. const that = this
  1508. // Sortable.create(tbody, {
  1509. var sortable = Sortable.create(tbody, {
  1510. disabled: that.dropState,
  1511. onChoose({ newIndex, oldIndex }) {
  1512. if (that.dropState == true) {
  1513. sortable.destroy()
  1514. }
  1515. },
  1516. onEnd({ newIndex, oldIndex }) {
  1517. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  1518. that.table2.list.splice(newIndex, 0, currRow)
  1519. console.log('索引', newIndex)
  1520. console.log('拖动数据', currRow)
  1521. console.log('上', that.table2.list[newIndex - 1])
  1522. console.log('下', that.table2.list[newIndex + 1])
  1523. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  1524. for (let i = 0; i < that.table2.list.length; i++) {
  1525. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  1526. }
  1527. currRow.sort = 0
  1528. currRow.feedgroup = currRow.fname
  1529. console.log('拖动至最上方无值')
  1530. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  1531. currRow.sort = that.table2.list[newIndex - 1].sort
  1532. console.log('拖动值顺序等于上值顺序')
  1533. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  1534. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1535. currRow.feedgroup = currRow.fname
  1536. console.log('拖动至最下方无值')
  1537. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  1538. currRow.sort == that.table2.list[newIndex + 1].sort
  1539. console.log('拖动值顺序等于下值顺序')
  1540. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  1541. currRow.sort = that.table2.list[newIndex - 1].sort
  1542. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  1543. console.log('拖动至上下顺序一致')
  1544. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  1545. console.log('上下')
  1546. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  1547. console.log(newIndex)
  1548. for (let i = newIndex; i < that.table2.list.length; i++) {
  1549. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  1550. }
  1551. }
  1552. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1553. currRow.feedgroup = currRow.fname
  1554. console.log(that.table2.list[newIndex + 1].sort)
  1555. }
  1556. that.requestParam = {}
  1557. that.requestParam.common = { 'returnmap': '0' }
  1558. that.requestParam.data = []
  1559. that.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': that.table2.list }}
  1560. that.requestParam.data[0].children = []
  1561. that.requestParam.data[0].children[0] = { 'name': 'updateFTdetailSort', 'type': 'e', 'parammaps': {
  1562. id: '@insertSpotList.id',
  1563. pastureid: '@insertSpotList.pastureid',
  1564. sort: '@insertSpotList.sort',
  1565. feedgroup: '@insertSpotList.feedgroup'
  1566. }}
  1567. ExecDataByConfig(that.requestParam).then(response => {
  1568. console.log('顺序切换保存发送参数', that.requestParam)
  1569. if (response.msg === 'fail') {
  1570. that.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1571. } else {
  1572. that.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1573. that.getList2()
  1574. }
  1575. })
  1576. }
  1577. })
  1578. console.log(sortable.option('disabled'))
  1579. },
  1580. handleSearch2() {
  1581. console.log('点击了查询')
  1582. this.arrowDown2 = true
  1583. this.arrowUp2 = false
  1584. this.table2.getdataListParm.offset = 1
  1585. this.getList2()
  1586. },
  1587. handleRefresh2() {
  1588. console.log('点击了重置')
  1589. this.table2.getdataListParm.parammaps.fname = ''
  1590. this.table2.getdataListParm.parammaps.feedgroup = ''
  1591. this.table2.getdataListParm.parammaps.fweight = ''
  1592. this.table2.getdataListParm.parammaps.autosecondname = ''
  1593. this.table2.getdataListParm.parammaps.islockcount = '0'
  1594. this.table2.getdataListParm.parammaps.sort = ''
  1595. this.table2.getdataListParm.offset = 1
  1596. this.getList2()
  1597. },
  1598. // 详情新增
  1599. handleCreate2() {
  1600. console.log('点击了详情新增', this.table2.list)
  1601. // 编辑true/不可编辑false
  1602. // 新增操true,编辑false,编辑保存false
  1603. console.log(11)
  1604. for (let i = 0; i < this.table2.list.length; i++) {
  1605. if (this.table2.list[i].Edit === true) {
  1606. console.log(123)
  1607. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1608. return false
  1609. }
  1610. }
  1611. console.log(this.table2.list)
  1612. if (this.table2.list.length == 0) {
  1613. var mysort = 0
  1614. } else {
  1615. var mysort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1616. }
  1617. this.table2.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'groupEdit': false, 'groupNoEdit': true, 'enable': 1, 'feedgroup': '', 'fid': '', 'fname': '', 'fweight': '', 'autosecond': '0', 'islockcount': '0', 'sort': mysort })
  1618. console.log(this.table2.list)
  1619. },
  1620. changeFname(item, row) {
  1621. console.log(item, row)
  1622. this.table2.temp.fname = this.feedNameList.find(obj => obj.id == item).fname
  1623. row.fname = this.feedNameList.find(obj => obj.id == item).fname
  1624. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  1625. this.table2.temp.preftid = '0'
  1626. } else {
  1627. this.table2.temp.preftid = item
  1628. }
  1629. if (row.sort == '') {
  1630. row.feedgroup = this.table2.temp.fname
  1631. } else {
  1632. if (row.isCreate == true) { // 新增状态下
  1633. for (let i = 1; i < this.table2.list.length; i++) {
  1634. if (this.table2.list[i].sort == row.sort) {
  1635. console.log(this.table2.list[i])
  1636. row.feedgroup = this.table2.list[i].feedgroup
  1637. break
  1638. } else {
  1639. row.feedgroup = this.table2.temp.fname
  1640. }
  1641. }
  1642. } else if (row.isUpdateSave == true) { // 编辑状态下
  1643. var Arr = []
  1644. for (let i = 0; i < this.table2.list.length; i++) {
  1645. Arr.push(this.table2.list[i].sort)
  1646. }
  1647. var Count = 0
  1648. for (let i = 0; i < Arr.length; i++) {
  1649. if (Arr[i] == row.sort) {
  1650. Count++
  1651. }
  1652. }
  1653. for (let i = 0; i < this.table2.list.length; i++) {
  1654. if (Count > 1) {
  1655. row.feedgroup = this.table2.list[i].feedgroup
  1656. console.log(111, this.table2.list[i].feedgroup)
  1657. break
  1658. } else if (Count == 1) {
  1659. row.feedgroup = this.table2.temp.fname
  1660. console.log(222, this.table2.temp.fname)
  1661. }
  1662. }
  1663. }
  1664. }
  1665. },
  1666. bort(row) {
  1667. if (row.isCreate == true) {
  1668. if (row.sort !== '') {
  1669. for (let i = 1; i < this.table2.list.length; i++) {
  1670. if (this.table2.list[i].sort == parseInt(row.sort)) {
  1671. row.feedgroup = this.table2.list[i].feedgroup
  1672. return false
  1673. } else {
  1674. row.feedgroup = row.fname
  1675. }
  1676. }
  1677. } else {
  1678. row.feedgroup = row.fname
  1679. }
  1680. } else if (row.isUpdateSave == true) {
  1681. if (row.sort !== '') {
  1682. for (let i = 0; i < this.table2.list.length; i++) {
  1683. if (this.table2.list[i].sort == row.sort) {
  1684. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  1685. if (this.table2.list[i].id !== row.id) {
  1686. row.isGroupDisabled = true
  1687. row.feedgroup = this.table2.list[i].feedgroup
  1688. break
  1689. }
  1690. } else {
  1691. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  1692. row.isGroupDisabled = true
  1693. row.feedgroup = row.fname
  1694. }
  1695. }
  1696. } else {
  1697. row.feedgroup = row.fname
  1698. }
  1699. }
  1700. },
  1701. createData2(row) {
  1702. console.log('点击了详情新增保存', row)
  1703. this.table2.temp.pastureid = Cookies.get('pastureid')
  1704. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1705. this.table2.temp.fid = row.fid
  1706. this.table2.temp.fname = this.table2.temp.fname
  1707. this.table2.temp.fweight = row.fweight
  1708. this.table2.temp.islockcount = row.islockcount
  1709. this.table2.temp.sort = row.sort
  1710. this.table2.temp.feedgroup = row.feedgroup
  1711. this.table2.temp.preftid = this.table2.temp.preftid
  1712. this.table2.temp.autosecond = row.autosecond
  1713. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1714. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1715. return false
  1716. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1717. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1718. return false
  1719. } else if (this.table2.temp.fid == '') {
  1720. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1721. return false
  1722. } else if (this.table2.temp.fweight == '') {
  1723. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1724. return false
  1725. } else if (this.table2.temp.autosecond == '') {
  1726. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1727. return false
  1728. }
  1729. if (this.table2.temp.sort !== '') {
  1730. this.table2.temp.sort = this.table2.temp.sort
  1731. } else {
  1732. console.log(this.table2.list.length)
  1733. if (this.table2.list.length == 1) {
  1734. this.table2.temp.sort = 0
  1735. } else {
  1736. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1737. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1738. }
  1739. }
  1740. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1741. if (parseInt(this.table2.temp.preftid) > 0) {
  1742. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1743. return false
  1744. }
  1745. }
  1746. // 校验顺序是否>=0
  1747. var ruleSort = /^\d+$/
  1748. if (!ruleSort.test(this.table2.temp.sort)) {
  1749. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1750. return false
  1751. }
  1752. // 检验重量>0
  1753. // this.table2.temp.fweight = formatNum(this.table2.temp.fweight, 2) //根据默认参数设置小数位数
  1754. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1755. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1756. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1757. return false
  1758. }
  1759. this.isokDisable = true
  1760. setTimeout(() => {
  1761. this.isokDisable = false
  1762. }, 1000)
  1763. this.requestParam.common = { 'returnmap': '0' }
  1764. this.requestParam.data = []
  1765. this.requestParam.data[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  1766. pastureid: this.table2.temp.pastureid,
  1767. ftid: this.table2.getdataListParm.parammaps.ftid,
  1768. fid: row.fid,
  1769. fname: this.table2.temp.fname,
  1770. fweight: row.fweight,
  1771. islockcount: row.islockcount,
  1772. sort: row.sort,
  1773. feedgroup: row.feedgroup,
  1774. preftid: this.table2.temp.preftid,
  1775. autosecond: row.autosecond
  1776. }}
  1777. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1778. pastureid: this.table2.temp.pastureid,
  1779. ftid: this.table2.getdataListParm.parammaps.ftid,
  1780. type: this.table2.getdataListParm.parammaps.fttypeid
  1781. }}
  1782. ExecDataByConfig(this.requestParam).then(response => {
  1783. console.log('新增保存发送参数', this.requestParam)
  1784. if (response.msg !== 'fail') {
  1785. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1786. this.getList2()
  1787. } else {
  1788. failproccess(response, this.$notify)
  1789. }
  1790. })
  1791. },
  1792. createCancel2(row) {
  1793. console.log('点击了详情新增取消')
  1794. for (let i = 0; i < this.table2.list.length; i++) {
  1795. if (row.myId === this.table2.list[i].myId) {
  1796. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  1797. }
  1798. if (listIndex > -1) {
  1799. this.table2.list.splice(listIndex, 1)
  1800. return
  1801. }
  1802. }
  1803. this.getDialogList()
  1804. },
  1805. // 详情编辑
  1806. handleUpdate2(row) {
  1807. console.log('详情编辑', row)
  1808. this.dropState = true
  1809. row.isGroupDisabled = false
  1810. row.islockcount = String(row.islockcount)
  1811. row.fid = String(row.fid)
  1812. row.autosecond = String(row.autosecond)
  1813. this.table2.temp.fname = row.fname
  1814. this.table2.temp.preftid = row.preftid
  1815. const rowArr = []
  1816. for (let i = 0; i < this.table2.list.length; i++) {
  1817. if (this.table2.list[i].Edit == true) {
  1818. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1819. return false
  1820. }
  1821. rowArr.push(this.table2.list[i].sort)
  1822. }
  1823. var count = 0
  1824. for (let i = 0; i < rowArr.length; i++) {
  1825. if (rowArr[i] == row.sort) {
  1826. count++
  1827. }
  1828. }
  1829. // 判断是否有相同顺序,如果没有饲料组不可编辑,若有饲料组可编辑
  1830. if (count == 1) {
  1831. // 饲料组编辑false,不可编辑true
  1832. row.groupEdit = false
  1833. row.groupNoEdit = true
  1834. // 编辑true,不可编辑false
  1835. row.Edit = true
  1836. row.NoEdit = false
  1837. // 新增false,编辑false,编辑保存true
  1838. row.isCreate = false
  1839. row.isUpdate = false
  1840. row.isUpdateSave = true
  1841. } else if (count > 1) {
  1842. // 饲料组编辑true,不可编辑false
  1843. row.groupEdit = true
  1844. row.groupNoEdit = false
  1845. console.log(222)
  1846. // 编辑true,不可编辑false
  1847. row.Edit = true
  1848. row.NoEdit = false
  1849. // 新增false,编辑false,编辑保存true
  1850. row.isCreate = false
  1851. row.isUpdate = false
  1852. row.isUpdateSave = true
  1853. return false
  1854. }
  1855. },
  1856. updateData2(row) {
  1857. console.log('点击了详情编辑保存111', row)
  1858. this.isokDisable = true
  1859. setTimeout(() => {
  1860. this.isokDisable = false
  1861. }, 1000)
  1862. this.table2.temp.pastureid = row.pastureid
  1863. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1864. this.table2.temp.fid = row.fid
  1865. this.table2.temp.fname = this.table2.temp.fname
  1866. this.table2.temp.fweight = row.fweight
  1867. this.table2.temp.islockcount = row.islockcount
  1868. this.table2.temp.sort = row.sort
  1869. this.table2.temp.feedgroup = row.feedgroup
  1870. this.table2.temp.preftid = this.table2.temp.preftid
  1871. this.table2.temp.autosecond = row.autosecond
  1872. this.table2.temp.id = row.id
  1873. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1874. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1875. return false
  1876. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1877. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1878. return false
  1879. } else if (this.table2.temp.fid == '') {
  1880. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1881. return false
  1882. } else if (this.table2.temp.fweight == '') {
  1883. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1884. return false
  1885. } else if (this.table2.temp.autosecond == '') {
  1886. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1887. return false
  1888. }
  1889. if (this.table2.temp.sort !== '') {
  1890. this.table2.temp.sort = this.table2.temp.sort
  1891. } else {
  1892. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1893. }
  1894. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1895. if (parseInt(this.table2.temp.preftid) > 0) {
  1896. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1897. return false
  1898. }
  1899. }
  1900. // 校验顺序是否>=0
  1901. var ruleSort = /^\d+$/
  1902. if (!ruleSort.test(this.table2.temp.sort)) {
  1903. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1904. return false
  1905. }
  1906. // this.table2.temp.fweight = formatNum(this.table2.temp.fweight, 2) //根据默认参数设置小数位数
  1907. // 检验重量>0
  1908. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1909. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1910. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1911. return false
  1912. }
  1913. this.requestParam.common = { 'returnmap': '0' }
  1914. this.requestParam.data = []
  1915. this.requestParam.data[0] = { 'name': 'updateFTdetail', 'type': 'e', 'parammaps': {
  1916. pastureid: row.pastureid,
  1917. ftid: this.table2.getdataListParm.parammaps.ftid,
  1918. fid: row.fid,
  1919. fname: this.table2.temp.fname,
  1920. fweight: row.fweight,
  1921. islockcount: row.islockcount,
  1922. sort: row.sort,
  1923. feedgroup: row.feedgroup,
  1924. preftid: this.table2.temp.preftid,
  1925. autosecond: row.autosecond,
  1926. id: row.id
  1927. }}
  1928. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1929. pastureid: row.pastureid,
  1930. ftid: this.table2.getdataListParm.parammaps.ftid,
  1931. type: this.table2.getdataListParm.parammaps.fttypeid
  1932. }}
  1933. this.requestParam.data[2] = { 'name': 'updateFTdetailbySort', 'type': 'e', 'parammaps': {
  1934. pastureid: row.pastureid,
  1935. ftid: this.table2.getdataListParm.parammaps.ftid,
  1936. sort: row.sort,
  1937. feedgroup: row.feedgroup
  1938. }}
  1939. ExecDataByConfig(this.requestParam).then(response => {
  1940. console.log('新增保存发送参数', this.requestParam)
  1941. if (response.msg !== 'fail') {
  1942. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1943. this.getList2()
  1944. this.dropState = false
  1945. } else {
  1946. failproccess(response, this.$notify)
  1947. }
  1948. })
  1949. },
  1950. updateCancel2(row) {
  1951. console.log('点击了详情编辑取消')
  1952. // 饲料组编辑false,不可编辑true
  1953. row.groupEdit = false
  1954. row.groupNoEdit = true
  1955. // 编辑false,不可编辑true
  1956. row.Edit = false
  1957. row.NoEdit = true
  1958. // 新增false,编辑true,编辑保存false
  1959. row.isCreate = false
  1960. row.isUpdate = true
  1961. row.isUpdateSave = false
  1962. this.getList2()
  1963. this.dropState = false
  1964. },
  1965. // 详情删除
  1966. handleRowDelete2(row) {
  1967. console.log('点击了行内删除')
  1968. MessageBox.confirm('是否确认删除此信息?', {
  1969. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1970. }).then(() => {
  1971. this.requestParam.common = { 'returnmap': '0' }
  1972. this.requestParam.data = []
  1973. this.requestParam.data[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1974. pastureid: row.pastureid,
  1975. id: row.id
  1976. }}
  1977. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1978. pastureid: row.pastureid,
  1979. ftid: this.table2.getdataListParm.parammaps.ftid,
  1980. type: this.table2.getdataListParm.parammaps.fttypeid
  1981. }}
  1982. ExecDataByConfig(this.requestParam).then(response => {
  1983. console.log('新增保存发送参数', this.requestParam)
  1984. if (response.msg === 'fail') {
  1985. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1986. } else {
  1987. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1988. this.getList2()
  1989. }
  1990. })
  1991. }).catch(() => {
  1992. this.$message({ type: 'info', message: '已取消删除' })
  1993. })
  1994. },
  1995. handleSelectionChange2(val) {
  1996. console.log('勾选数据', val)
  1997. this.selectList2 = val
  1998. },
  1999. handleDelete2() {
  2000. console.log('点击了删除')
  2001. if (this.selectList2.length == 0) {
  2002. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  2003. } else {
  2004. MessageBox.confirm('是否确认删除此信息?', {
  2005. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  2006. }).then(() => {
  2007. console.log(this.selectList)
  2008. this.requestParam.common = { 'returnmap': '0' }
  2009. this.requestParam.data = []
  2010. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  2011. this.requestParam.data[0].children = []
  2012. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2013. id: '@insertSpotList.id',
  2014. pastureid: '@insertSpotList.pastureid'
  2015. }}
  2016. ExecDataByConfig(this.requestParam).then(response => {
  2017. console.log('删除保存发送参数', this.requestParam)
  2018. if (response.msg === 'fail') {
  2019. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2020. } else {
  2021. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  2022. this.getList2()
  2023. }
  2024. })
  2025. })
  2026. }
  2027. },
  2028. // 拆分预混料
  2029. handleSplitPremix(row) {
  2030. console.log('点击了拆分预混料')
  2031. MessageBox.confirm('是否确认拆分当前预混料?', {
  2032. confirmButtonText: '确认',
  2033. cancelButtonText: '取消',
  2034. type: 'warning'
  2035. }).then(() => {
  2036. this.requestParam.name = 'splitFTpre'
  2037. this.requestParam.parammaps = {}
  2038. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  2039. this.requestParam.parammaps.preftid = row.preftid
  2040. this.requestParam.parammaps.ftdid = row.id
  2041. this.requestParam.parammaps.pastureid = row.pastureid
  2042. this.requestParam.parammaps.feedgroup = row.feedgroup
  2043. this.requestParam.parammaps.sort = row.sort
  2044. this.requestParam.parammaps.fweight = row.fweight
  2045. PostDataByName(this.requestParam).then(response => {
  2046. if (response.msg === 'fail') {
  2047. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2048. } else {
  2049. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2050. this.getList2()
  2051. }
  2052. })
  2053. }).catch(() => {
  2054. this.$message({
  2055. type: 'info',
  2056. message: '已取消删除'
  2057. })
  2058. })
  2059. },
  2060. // 合成预混料
  2061. handleSyntheticPremix() {
  2062. console.log('点击了合成预混料', this.selectList2)
  2063. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2064. this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  2065. return false
  2066. } else {
  2067. if (this.selectList2.length > 1) {
  2068. for (let i = 0; i < this.selectList2.length; i++) {
  2069. if (parseInt(this.selectList2[i].preftid) > 0) {
  2070. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  2071. return false
  2072. }
  2073. }
  2074. if (this.selectList2[0].splitftpreid !== undefined) {
  2075. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  2076. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  2077. GetDataByName(this.detail.getdataListParm).then(response => {
  2078. if (response.data.list !== null) { // 不为空时得到比对数据
  2079. this.detail.list3 = response.data.list
  2080. const sortList = [] // 声明排序数组
  2081. var fweightSum = 0 // 总重量
  2082. for (let i = 0; i < this.selectList2.length; i++) {
  2083. const obj = {}
  2084. obj.fid = this.selectList2[i].fid
  2085. obj.fweight = this.selectList2[i].fweight
  2086. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  2087. sortList.push(obj)
  2088. }
  2089. // 排序
  2090. sortList.sort(function(a, b) {
  2091. return a.fid.localeCompare(b.fid)
  2092. })
  2093. var a = 0
  2094. if (this.detail.list3.length == sortList.length) {
  2095. for (let i = 0; i < this.detail.list3.length; i++) {
  2096. if (this.detail.list3[i].fid == sortList[i].fid && (this.detail.list3[i].fweight / this.detail.list3[i].sumWeight).toFixed(2) == (sortList[i].fweight / fweightSum).toFixed(2)) {
  2097. a++
  2098. }
  2099. }
  2100. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  2101. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  2102. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  2103. GetDataByName(this.detail.getdataListParm2).then(response => {
  2104. if (response.data.list !== null) {
  2105. this.detail.dialogStatus = 'SyntheticPremix'
  2106. this.detail.dialogFormVisible = true
  2107. this.detail.list = this.selectList2
  2108. this.detail.list2 = response.data.list
  2109. this.detail.disabled = true
  2110. setTimeout(() => {
  2111. this.detail.listLoading = false
  2112. }, 100)
  2113. } else {
  2114. this.detail.list2 = []
  2115. }
  2116. })
  2117. } else {
  2118. this.detail.dialogStatus = 'SyntheticPremix'
  2119. this.detail.dialogFormVisible = true
  2120. this.detail.list = this.selectList2
  2121. this.detail.disabled = false
  2122. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2123. setTimeout(() => {
  2124. this.detail.listLoading = false
  2125. }, 100)
  2126. }
  2127. } else {
  2128. this.detail.dialogStatus = 'SyntheticPremix'
  2129. this.detail.dialogFormVisible = true
  2130. this.detail.list = this.selectList2
  2131. this.detail.disabled = false
  2132. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2133. setTimeout(() => {
  2134. this.detail.listLoading = false
  2135. }, 100)
  2136. }
  2137. } else {
  2138. this.detail.list3 = []
  2139. this.detail.dialogStatus = 'SyntheticPremix'
  2140. this.detail.dialogFormVisible = true
  2141. this.detail.list = this.selectList2
  2142. this.detail.disabled = false
  2143. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2144. setTimeout(() => {
  2145. this.detail.listLoading = false
  2146. }, 100)
  2147. }
  2148. })
  2149. } else {
  2150. this.detail.dialogStatus = 'SyntheticPremix'
  2151. this.detail.dialogFormVisible = true
  2152. this.detail.list = this.selectList2
  2153. this.detail.disabled = false
  2154. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2155. setTimeout(() => {
  2156. this.detail.listLoading = false
  2157. }, 100)
  2158. }
  2159. } else {
  2160. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  2161. return false
  2162. }
  2163. }
  2164. },
  2165. // 畜生类别
  2166. changeLivestockType2(item) {
  2167. this.detail.list2[0].ccname = this.livestockTypeList.find(obj => obj.value === item).label
  2168. },
  2169. syntheticPremixData() {
  2170. console.log('点击了合成预混料确认')
  2171. if (this.detail.disabled == true) { // 原预混料
  2172. let sumFweight = 0
  2173. for (let i = 0; i < this.detail.list.length; i++) {
  2174. sumFweight += parseFloat(this.detail.list[i].fweight)
  2175. }
  2176. sumFweight = sumFweight.toFixed(2)
  2177. this.isokDisable = true
  2178. setTimeout(() => {
  2179. this.isokDisable = false
  2180. }, 1000)
  2181. this.requestParam.common = { 'returnmap': '0' }
  2182. this.requestParam.data = []
  2183. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2184. this.requestParam.data[0].children = []
  2185. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2186. pastureid: '@insertSpotList.pastureid',
  2187. id: '@insertSpotList.id'
  2188. }}
  2189. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2190. this.requestParam.data[1].children = []
  2191. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2192. pastureid: Cookies.get('pastureid'),
  2193. ftid: this.table2.getdataListParm.parammaps.ftid,
  2194. fid: this.detail.list2[0].id,
  2195. fname: '@insertSpotList2.tname',
  2196. fweight: sumFweight,
  2197. islockcount: '0',
  2198. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2199. feedgroup: '@insertSpotList2.tname',
  2200. preftid: this.detail.list2[0].id,
  2201. autosecond: this.detail.list[0].autosecond
  2202. }}
  2203. ExecDataByConfig(this.requestParam).then(response => {
  2204. console.log('合成预混料保存发送参数', this.requestParam)
  2205. if (response.msg === 'fail') {
  2206. const tname = new RegExp("key 'tname'")
  2207. if (tname.test(response.data)) {
  2208. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2209. } else {
  2210. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2211. }
  2212. } else {
  2213. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2214. this.detail.dialogFormVisible = false
  2215. this.getList()
  2216. this.getList2()
  2217. this.getDownList()
  2218. }
  2219. })
  2220. } else { // 现生成预混料
  2221. if (this.detail.list2[0].tname == '' && this.detail.list2[0].ccid == '') {
  2222. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  2223. return false
  2224. } else if (this.detail.list2[0].tname == '') {
  2225. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  2226. return false
  2227. } else if (this.detail.list2[0].ccid == '') {
  2228. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  2229. return false
  2230. }
  2231. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2232. if (pattern.test(this.detail.list2[0].tname)) {
  2233. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  2234. return false
  2235. }
  2236. let sumFweight = 0
  2237. for (let i = 0; i < this.detail.list.length; i++) {
  2238. sumFweight += parseFloat(this.detail.list[i].fweight)
  2239. }
  2240. sumFweight = sumFweight.toFixed(2)
  2241. console.log(sumFweight)
  2242. this.isokDisable = true
  2243. setTimeout(() => {
  2244. this.isokDisable = false
  2245. }, 1000)
  2246. if (this.detail.list2[0].tcolor == null) {
  2247. this.detail.list2[0].tcolor = '#CCCCCC'
  2248. }
  2249. this.requestParam.common = { 'returnmap': '0' }
  2250. this.requestParam.data = []
  2251. this.requestParam.data[0] = { 'name': 'insertFT', 'type': 'e', 'parammaps': {
  2252. pastureid: Cookies.get('pastureid'),
  2253. tcode: this.detail.list2[0].tcode,
  2254. tname: this.detail.list2[0].tname,
  2255. tcolor: this.detail.list2[0].tcolor,
  2256. ccid: this.detail.list2[0].ccid,
  2257. ccname: this.detail.list2[0].ccname,
  2258. fttype: this.detail.list2[0].fttype,
  2259. fttypeid: this.detail.list2[0].fttypeid,
  2260. source: this.detail.list2[0].source,
  2261. remark: this.detail.list2[0].remark,
  2262. enable: this.detail.list2[0].enable
  2263. }}
  2264. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2265. this.requestParam.data[1].children = []
  2266. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2267. pastureid: '@insertSpotList.pastureid',
  2268. ftid: '@insertFT.LastInsertId',
  2269. fid: '@insertSpotList.fid',
  2270. fname: '@insertSpotList.fname',
  2271. fweight: '@insertSpotList.fweight',
  2272. islockcount: '@insertSpotList.islockcount',
  2273. sort: '@insertSpotList.sort',
  2274. feedgroup: '@insertSpotList.feedgroup',
  2275. preftid: '@insertSpotList.preftid',
  2276. autosecond: '@insertSpotList.autosecond'
  2277. }}
  2278. this.requestParam.data[1].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2279. pastureid: '@insertSpotList.pastureid',
  2280. id: '@insertSpotList.id'
  2281. }}
  2282. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2283. this.requestParam.data[2].children = []
  2284. this.requestParam.data[2].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2285. pastureid: Cookies.get('pastureid'),
  2286. ftid: this.table2.getdataListParm.parammaps.ftid,
  2287. fid: '@insertFT.LastInsertId',
  2288. fname: '@insertSpotList2.tname',
  2289. fweight: sumFweight,
  2290. islockcount: '0',
  2291. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2292. feedgroup: '@insertSpotList2.tname',
  2293. preftid: '@insertFT.LastInsertId',
  2294. autosecond: this.detail.list[0].autosecond
  2295. }}
  2296. ExecDataByConfig(this.requestParam).then(response => {
  2297. console.log('合成预混料保存发送参数', this.requestParam)
  2298. if (response.msg === 'fail') {
  2299. const tname = new RegExp("key 'tname'")
  2300. if (tname.test(response.data)) {
  2301. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2302. } else {
  2303. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2304. }
  2305. } else {
  2306. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2307. this.detail.dialogFormVisible = false
  2308. this.getList()
  2309. this.getList2()
  2310. this.getDownList()
  2311. }
  2312. })
  2313. }
  2314. },
  2315. handleFormulationEvaluation(row) {
  2316. console.log(row)
  2317. this.$router.push({ path: '/statisticalAnalysis/FormulationEvaluation', query: { tname: row.tname }})
  2318. this.$router.push({
  2319. name: 'FormulationEvaluation',
  2320. params: {
  2321. tname: row.tname,
  2322. ftid: row.id,
  2323. pastureid: row.pastureid,
  2324. inputDatetime: [new Date('2021-03-01'), new Date('2021-03-30')], // 日期后台待传
  2325. startTime: '2021-03-01',
  2326. stopTime: '2021-03-30'
  2327. }
  2328. })
  2329. }
  2330. }
  2331. }
  2332. </script>
  2333. <style lang="scss" scoped>
  2334. .search{margin-top:10px;}
  2335. .table{margin-top:10px;}
  2336. .table2{margin-top:10px;}
  2337. $width:350px;
  2338. $left:325px;
  2339. .selectInput{
  2340. position: relative;
  2341. display: inline-block;
  2342. .Input{width: $width;position: relative;}
  2343. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2344. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2345. .selectUl{
  2346. z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  2347. li{
  2348. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  2349. a{float:left;width: 80px;}
  2350. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  2351. }
  2352. }
  2353. }
  2354. .template{
  2355. background: #fff;
  2356. position: relative;
  2357. }
  2358. .detail{
  2359. background: #fff;
  2360. position: relative;
  2361. }
  2362. .templateDialog{
  2363. background: #fff;
  2364. position: relative;
  2365. }
  2366. .detailDialog{
  2367. background: #fff;
  2368. position: relative;
  2369. }
  2370. </style>