f9a997de144e0b057003ae5d71404f80849b69ec.svn-base 128 KB

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